Using Java

CSci 5106: Programming Languages

I am going to assume that you have used Java already in earlier courses and within a Unix environment. For the moment, therefore, I limit myself to the following comments:

To clarify the latter point, suppose you have stored the following Java program in a file called

import; class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }

You would then compile this using the command

% javac %

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:

% java HelloWorld Hello World %

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.