If you are asking how to run javac.exe from anywhere in a prompt (e.g. C:\java.exe MyApp), You will need
to modify the Path variable in your Environment variables (for Windows). If you are running XP,
1) go to control panel
2) click the System icon
3) openthe Advanced tab
4) click the Environment Variables button
5) under System variables, highlight the Path variable
6) click Edit
7) type in the full path to the directory containing bin in your JDK
8) OK everything and then reboot your system. You should be good to go.
> Variable Name :
> javac bin
> Variable Value:
> F:\j2sdk1.4.1\bin
I think you may have misunderstood. When you get to step 6, you should get a small window titled
Edit System Variable correct? The first textfield should have Path written in it. The textfield
under the path textfield should have a bunch of paths to various directories something like so (yours will
differ a bit but don't worry about it):
%SystemRoot%\system32;%SystemRoot%\System32\Wbem notice each dir is separated by a ';'
Now, all you have to do is type the complete path to your bin directory at the end of the textfield. For example
if I were to add my bin directory, the above bold line would look like this:
%SystemRoot%\system32;%SystemRoot%\System32\Wbem;C:\Program Files\jdk1.5.0\bin
I hope that helps, PLEASE PLEASE DO NOT delete the lower textfield and save. It's meant for users to
append directories to the end of the field. If you delete info from the lower textfield, you may experience
some major OS problems. The PATH variable is used as a convenience of being able to type a command
from anywhere in the prompt. Any executable can be run from anywhere in a prompt provided that the
executable's directory is appended to the end of the Path variable. That's why you can run commands from
the prompt such as cd, exit, paint, ver, etc
*JDs First Program says "Hello Folks"*/
public class Hello {
public static void main (String [ ]args){
System.out.println("Hello Folks");
}
}
I am running my first simple program. It compiles on my Dell laptop and generates a .class file but doesn't execute. I get the error message below. I have already done all the system changes that were specified in the System Path area. This same code runs on my colleagues desk top with the same software.
I realize there is a path error but don't know where else to look. Any conflicts?
THIS IS A COPY OF THE COMMAND PROMPT SESSION..........
C:\Java>javac Hello.java
C:\Java>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
C:\Java>dir
Volume in drive C has no label.
Volume Serial Number is B47D-035A
Directory of C:\Java
09/02/2004 09:28 PM<DIR> .
09/02/2004 09:28 PM<DIR> ..
09/02/2004 09:55 PM415 Hello.class
09/02/2004 08:12 PM152 Hello.java
2 File(s)567 bytes
2 Dir(s) 18,406,572,032 bytes free
THIS IS THE PATH ENTRY FOR SEARCH RULES.........
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec Shared\System;C:\j2sdk1.4.2_05\bin
> C:\Java>java Hello
> Exception in thread "main"
> java.lang.NoClassDefFoundError: Hello
>
It will work if you use java -classpath . HelloThe reason it isn't working is (most likely) your computer's Classpath variable does not contain . and does not contain c:\Java. In the Command Prompt, if you enter "set" or "set Classpath" you should see what directories are in your system's Classpath. Sun and many on the forum recommend that you use the -classpath option to specify which directories are searched to find class files.