How to use Java on UNIX


On UNIX (i.e. troi) J++ does not exist. Instead, to use Java you need to use JDK, which is Sun's Java compiler (which uses the standard, by the way, the rest of the world uses, except Microsoft and J++). JDK also exists for Windows and is freeware. Look at the Sun Java Site for more details.

JDK does not have an IDE (integrated development environment) like J++. This means there is no nice program that let's you edit files, compile, and run, all from the same program (which is what an IDE is). Rather, you have to do things separately yourself using smaller tools (which is what UNIX is usually like).

Editing files
There are several programs on UNIX that you can use to edit text files. The most popular are emacs, vi, and pico. If you don't know any of these, I would suggest that you use pico for now, but invest some time sometime in using emacs. It's not easy to learn to use, but most computer geeks use it (although a lot of people may flame me and say that vi is better, there is a huge religious war out there about if emacs or vi is better) Note, you either need xwindows to run emacs or run the command line version (use emacs -nw)

To use pico just type pico and the name of the file you want to edit. This is the same editor used for pine, so you are probably somewhat used to it.

Compiling your program
To compile a file use javac. The syntax is javac < name of file.java> So, for example, to compile a file called Class1.java run
javac Class1.java
This will create a .class file for that file. You need a .class file for each .java file.

Running your program
To run your program use java. The syntax is java < name of class>. So if my main function was in a class called Class1 then I would call
java Class1
to run my code. Note that for compiling you include the extension, but for running you do not.

Other issues