[Current] [News] [Glance] [Search] [Instructions] [Links] [Handouts] [Project] [Outlines] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [EIJ] [API]
This document needs to be rewritten for our new linux environment.
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
.
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.)
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.
/usr/local/java/bin
to your path. The standard command
(which goes in your .cshrc) is
set path = (/usr/local/java/bin ${path})
A few helpful Unix hints:
!!
to do it again. (This special command is often
pronounced ``bang bang''.)
man
command, you would use !man
.
Fall 1997
Various Dates
17 January 2000
25 August 2000
[Current] [News] [Glance] [Search] [Instructions] [Links] [Handouts] [Project] [Outlines] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [EIJ] [API]
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.cs.grinnell.edu/~rebelsky/Courses/CS152/2000F/Handouts/java-use.html
Source text last modified Fri Aug 25 08:38:46 2000.
This page generated on Fri Aug 25 08:39:19 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu