/**
 * CS149 - Programming Fundamentals
 * Department of Computer Science
 * James Madison University
 * @version Fall 2019
 */

Objectives

The goal today is to get comfortable editing, compiling and executing Java programs in the terminal.

Instructions

  1. In the terminal, create a directory to store your work. Refer to the previous lab activity if you don't remember how.
  2. Start nano in your new directory and type in the class and method definitions for a new Java class. You should select a class name corresponding to a homework question that you haven't finished yet. For now, don't worry about Javadoc comments or finishing the method. Just put a single print statement in your main method. Save your file.
  3. Open a new terminal window (or tab) and navigate to the folder where you stored your Java file. You can compile the file using the javac command as follows:

    javac YourClass.java
    If there are any syntax errors fix them in nano and try again.
  4. Once you've compiled your file type ls in the terminal. You should see a .class file corresponding to your your Java class.
  5. Execute your Java program as follows:

    java YourClass
    Notice that we don't include the .java file extension when we are executing the code. We are actually executing the compiled .class file.
  6. Finish the method so that it works according the the homework specification.
  7. Test your method:
    • Copy and paste from the problem description to create a file containing the expected output: expected.txt.
    • Copy and paste your program output into a file named actual.txt.
    • Compare the two files using diff or meld:

      meld expected.txt actual.txt