Question: Let's do an exercise of copying a Java program to the Linux server (helps to double check if you are learning anything about scp) and
-
Let's do an exercise of copying a Java program to the Linux server (helps to double check if you are learning anything about scp) and running a Java program on the Linux sever (you will perform similar process for running C++ programs as well)
-
Download solution for Exercise1.java and input text file para1.txt para2.txt from Canvas and scp it to the Linux server to your home directory (i.e., ~/). Remember scp is always run (in a powershell/terminal) on your local computer (and not on the server).
More specifically, the java code should be able to handle:
A. Input redirection ( < ) in the Linux shell prompt (without any modification of the supplied starter code)
B. Command Line Parameter as args[0] (modify the code a little bit to do this)
As a test for the both approaches, use para1.txt and para2.txt as the suitable input filename.
-
Now, on the Linux server terminal, ensure your pwd is your home directory (use cd command to change directory if needed) and ensure Exercise1.java is there (of course, using the ls command).
-
Compile the Java program using the Java compiler
$ javac Exercise1.java
-
Run the java program using the JVM (without any modification of the starter code)
$ java Exercise1 < para1.txt
$ java Exercise1 < para2.txt
-
Copy-paste the para1.txt input to the program and observe its operations. In powershell click on the icon (top-left corner) to get menu and select EditPaste. You will need to press Control+D to stop the program.
-
Copy-paste a screenshot of the powershell/terminal (showing output from the program) in the space below:
Place a screenshot of powershell/terminal window here
-
Now modify the java code so that the above can be run as:
$ java Exercise1Modified para1.txt
$ java Exercise1Modified para2.txt
-
Copy-paste a screenshot of the powershell/terminal (showing output from the modified program) in the space below:
Place a screenshot of powershell/terminal window here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
