java -version
'' it will say what version it is.
Since I don't have an account on omicron, I don't know.) If you need
an account on omicron, you can contact
Robin Simon,
in the computer science department.
Java programs are run as follows. (These instructions are for unix,
with the Sun jdk installed. If you are using a different system, you
are on your own!) First, suppose you write a java
application (not an applet), and the entire program is in one class
called MyProgram
. Then this class should be in a file
called MyProgram.java
. You compile the program to byte
code with the command
javac MyProgram.javaThis will create a file called
MyProgram.class
. You can
run the program by saying
java MyProgram
More commonly, you will have several classes in several files.
Suppose the main()
function is in class
MyProgram
, which is in file MyProgram.java
,
as above, and this
program also uses classes X
, Y
, and
Z
, in files X.java
, Y.java
, and
Z.java
. Then you must compile all the files to byte code
with
javac MyProgram.java X.java Y.java Z.javaor, more simply,
javac *.javaThen you run the program the same way as above:
java MyProgrambecause
MyProgram
is the class with the
main()
function in it.
You can put more than one class in a file, but I find it easiest to
just make a separate file for each class. Then if the class is named
XXX
, the file should be named XXX.java
.
That is a pretty standard way of doing it.