I am going to assume that you have used Java already in earlier courses and within a Unix environment. As you probably know already, Java programs run on a virtual machine. Thus, to execute these programs, you first compile them, producing a byte code file that you then execute using a virtual machine emulator or a byte code interpreter.
To clarify the above observation, suppose you have stored the following Java program in a file called HelloWorld.java:
You would then compile this using the commandimport java.io.DataInputStream; class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
Read % as the prompt symbol here. As indicated, the compilation would end without errors in this case and will produce a bytecode file in HelloWorld.class. To execute this code, you would invoke the following command with the accompanying results:% javac HelloWorld.java %
In general, your code will build on class definitions available from other locations. To permit the use of such definitions, you have to set the CLASSPATH variable to include all the relevant paths. I assume that you are familiar with these details. If not, ask a question about it on the class discussion forum and someone will help you out.% java HelloWorld Hello World %
Created by gopalan atsign cs dot umn dot edu. Maintained by ngopalan atsign umn dot edu and evw atsign umn dot edu. Last modified: August 30, 2019.