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

  1. 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)

  1. 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.

  1. 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).

  1. Compile the Java program using the Java compiler

$ javac Exercise1.java

  1. Run the java program using the JVM (without any modification of the starter code)

$ java Exercise1 < para1.txt

$ java Exercise1 < para2.txt

  1. 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.

  1. 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

  1. Now modify the java code so that the above can be run as:

$ java Exercise1Modified para1.txt

$ java Exercise1Modified para2.txt

  1. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!