/** * CS149 - Programming Fundamentals * Department of Computer Science * James Madison University * @version Fall 2019 */
The goal today is to get comfortable editing, compiling and executing Java programs in the terminal.
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.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.ls
in the terminal. You
should see a .class
file corresponding to your your Java class.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.expected.txt
.actual.txt
.Compare the two files using diff
or meld
:
meld expected.txt actual.txt