Java代写,java作业代写:100%原创代码
当前位置:以往案例 > >案例代码:案例java OS Project – Java Shell Interface, v0.
2018-01-07

OS Project – Java Shell Interface, v0.7b

Objective: Implement a shell program in Java that accepts user commands and executes each command in a separate JVM process. This project is based on a textbook project.

*This shell program will run in Linux. If you do not know how to do this, I recommend installing Ubuntu in a VirtualBox VM. You can find tutorials online, but your overall goal is to install VirtualBox, download Ubuntu, then open the installer inside of VirtualBox to get it running. This video might help: https://www.youtube.com/watch?v=GGorVpzZQwA

· https://www.virtualbox.org/

· https://www.ubuntu.com/


Problem Description: Overall, your goal will be to create a program that allows users to enter commands. (Run cmd or PowerShell in windows or the Bash terminal in Linux to have an idea of how this should work). For ple, if you run “cat readme.txt”, it should print out readme.txt to the command line.

General setup of main class. (Name it YourLastNameYourFirstNameShell).

1. Read from System input (Scanner or BufferedReader)

2. Repeat

a. Print out a prompt (“KennedyShell>” or something, similar to Bash, see above)

b. Get input

c. If it is empty input, continue

d. Otherwise, figure out the command and associated parameters

i. i.e., you need to get the “cat” command and the “readme.txt” filename out of the input string

ii. create a ProcessBuilder object (a Java feature, see below)

iii. start the process

iv. get the output stream

v. send the output to the stream (to print it out)

Creating a process – Find details for these requirements at https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

· Process p = new ProcessBuilder("myCommand", "myArg").start();

Changing a directory

· ProcessBuilder has a method called directory.

· The current directory can be found with System.getProperty(“user.dir”)


Additional Feature – Implement a command, history, which when used will print out a listing of all previous commands that have been run in your program. It will print out each line with a number, beginning with 0. Additionally, the user can run historical commands by typing !x, where x is one of these numbers. The associated command will be re-run.


1539796847946440.png




1. When the user enters the command history, print out the history.

2. When the user enters !!, run the most recent command again, or an error message if no such command exists.

3. When the user enters !X, run command #X from the history.

4. Keep accepting commands and running them until the user enters exit.


Test your program with various Linux commands, such as ls, cat, and pwd. See https://www.youtube.com/watch?v=YHFzr-akOas for a quick tutorial.


Deliverables: Submit all source code in the package edu.frostburg.cosc460.LnameFnameShell. (Only the src folder, not your whole IDE project). Fill out and include the attached post-mortem questionnaire.

Include a few screenshots of your program running. Make sure everything is in a finished, professional level of quality.




Checklist

Check

Requirement

%

x

Read all specs

0

Install Linux

10

Post-mortem

10

Basic program

20

Processes

20

History

30

Documentation

10

Bugs / Typos / etc

-X


在线提交订单