Fundamentals of Computer Science II (CSC-152 2000S)


Using Java on the MathLAN Network

There are two basic steps to running a Java program in any environment: you must compile the program and then interpret the compiled program. Compilation verifies the syntax of your program and translates your program into a language that the computer can more easily understand. The interpreter then executes this more easily understandable language.

To compile a program named XXX.java in the MathLAN, type

% /home/rebelsky/bin/jc XXX.java

The ``jc'' stands for ``Java compiler''. If there are no observable errors in your program, you will see another prompt after about one minute (yes, the MathLAN is slwo). If there are observable errors in your program, the compiler will print a list of line/error pairs. Most people find the error messages unreadable, so feel free to ask me for help understanding them. Usually, if you look closely at the line (or near the line), you'll find the error.

When compilation succeeds, the compiler creates a file called XXX.class. You can confirm this by typing

% ls

To execute the compiled program, type

% /home/rebelsky/bin/ji XXX

The ``ji'' stands for ``Java interpreter''.

These commands are set up to work with reasonable variants. Hence, you can also leave off the .java when compiling or add it when running the program.

When you get sick of typing /home/rebelsky/bin, add the following line to your .cshrc file. This file is located in your home directory. Ask Sam or a tutor if you need help adding the line.

set path = (/home/rebelsky/bin $path)

Afterwards, close your terminal window and open another one. From then on, you can use just ji and jc.

Copying Classes

If you are importing classes such as SimpleInput and SimpleOutput, it is likely that you will need to make copies of those classes in the current directory. (Later in the semester we may talk about how to create your own library of standard classes.)

Warning!

Note that you are running special scripts designed for my class. If you would prefer to execute the actual Java compiler and interpreter, you'll need to make a few changes to your .cshrc file (this is only for more advanced students). The standard java compiler is called javac. The standard java interpreter is called java. Both can be found in /usr/local/java/bin

In order to use these, you will probably want to do the following.

Unix Issues

A few helpful Unix hints:

History

Fall 1997

Various Dates

17 January 2000


Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/2000S/Handouts/java-use.html

Source text last modified Mon Jan 17 15:02:33 2000.

This page generated on Mon Jan 17 16:40:11 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at rebelsky@grinnell.edu