Marc's instructions assume that you have set the PATH variable. If you haven't done this yet, then check out step 5 in the Installation Instructions. These instructions are for Java 1.4.2, so the exact path to use in the PATH variable will be different if you are using Java 1.5. I hope you will be able to make the necessary adjustments. If not, please come back to tell us what problems you have encountered.
I'm getting rather more success now (Had to blow the cobwebs out of my brain and remember how to play around with DOS).
I have adjusted the PATH environmental variable (I'm running Windows XP), and so I am now able to run the javac program to create the classes as I wanted to.
I am still having difficulty actually running the application, though. The path of the java folder is c:\program files\java. In the java folder are two more folders, jdk1.5.0_06 and jre1.5.0_06 . If I type SET CLASSPATH= into the command line then things happen - but this isn't very satisfactory! What should I set the CLASSPATH variable to to ensure that I can always complile the .java program from any directory on my computer (so that the compiled .class file sits in the same directory)?
Thanks again in anticipation.
Joined: Dec 06, 2001
At this point, you should NOT use the CLASSPATH variable at all. It will just cause more headaches than it is worth. You should only worry about the PATH variable at this point. In your case, it looks like PATH should contain "c:\program files\java\jdk1.5.0_06\bin". Double check that this is the folder that contains the javac.exe and java.exe programs. If not, you should find where these two programs are installed and put that directory in the PATH variable.
Now when you want to compile a program, you should open a command prompt window and change to the directory where you have saved your .java files. Then you run the following commands:
Of course, you should replace "MyProgram" with the actual name of the class you created. Also notice that when you use the javac compiler, you need to specify a file name which includes the ".java" extension. However, when you run the program with "java MyProgram" you use just the class name without any file name extension. Also, the class name is case sensitive, even if your operating system is not.
I hope this helps you run your program. Please let us know how it works out.
Joined: Dec 31, 2005
Thanks Layne - and everyone else who has been generous with their time on this one. Much appreciated.
Things are actually working - and I am making satisfactory progress.
One more question... Is it necessary to name the .java file the same name as the class that is defined within it?
Originally posted by Mike Hudek: ... Is it necessary to name the .java file the same name as the class that is defined within it? ...
Only if that class (or interface) is public.
A .java source file can contain at most one public class or interface definition. (It does not need to contain any.) If a class or interface is declared public, then the source file must share the name of that class or interface. [ January 15, 2006: Message edited by: marc weber ]