Nav-Bar 

Getting Java Working 


Java Zone Index Page Search the Java Zone Site Java Dictionary

View the Tutorials Archive

What is Java? Java syntax and general style guide How to get Java running
Links to relevant sites

Email me

People always seem to have problems running Java. For me, I just clicked the install button and it works - but as I got a few requests, here's the guide to running Java.
 
  1. Install Java
  2. Create a directory where you want to store all the programs you write
  3. Write some Java source code and save it in this directory
  4. Goto an MS-DOS prompt or a UNIX terminal or whatever
  5. Make the CURRENT DIRECTORY the directory with you Java source code in
  6. Type "javac programName.java" to compile your Java source code, and "java programName" to run it.


MS-DOS Screenshot
 

There are a few places this procedure doesn't work. For example, you might get an error message "Unknown command or file name" indicating that the "javac" command can't be found. This will be due to the command not being in the command path. To get it working, at the MS-DOS prompt type:

     PATH = [full path of where the "javac" command is]

The command is usually in the "BIN" drawer of your Java installation. Once you've located this you need the full MS-DOS path.

MS-DOS Screenshot 2

Here the full MS-DOS path is "C:\PROGRA~1\JDK116\BIN"

So at the MS-DOS prompt you would type PATH = C:\PROGRA~1\JDK116\BIN

Now all of the command to run Java such as "javac" and "java" can be found. It is probably worthwhile adding this "path" line to your Autoexec.bat file so it is executed every time you boot up your computer.

The documents that come with Java explain all this fully though, so you should read these if you have any problems.

3-4-99