Compile and Run Java Programs from the command line

Windows Users: Install Putty and PSCP if you have not already done so.

Pre-Conditions

  1. You are remotely connected to a CS Linux workstation.
  2. You have created a project directory on your CS Linux account (and you know where it is located).
  3. You have copied your local files to that directory.

Once you are connected (logged in) to a CS Linux workstation, and have copied your program files to your CS account's program directory, follow these instructions.

  1. Navigate to your CS directory to find files.
    cd private/cs400/programs/practice
  2. List all files in current directory to confirm that your .java files are present.
    ls -al

    CAUTION: If the *.java files are not in the list, you will need to find them or copy them again.

  3. Compile your Java source code
    javac *.java
  4. Run your Java program from command line and again with a command-line argument.
    java Hello 
    java Hello Bucky 
    
  5. Redirect your program's output to a file named results.txt
    java TestSuite > results.txt
  6. review the contents of the results.txt file
    cat results.txt
  7. Handin your program files as directed on the assignment page.