This was a pain in the neck and took several tries. The problem lies in the new windows installer, JDK 6 Update 21, not setup the PATH or CLASS environment variables.
To see what the current path looks like:
set PATH
To set the path:
To set the class path:set PATH=%PATH%;C:\Program Files\Java\jdk1.6.0_21\bin
set CLASSPATH=%CLASSPATH%;.
To verify that you have the path correct type:
javac -version
Now I am ready to build.
To open a text window:
notepad Hello.java
Enter the following text into the text editor
class Hello{
public static void main (String args[]){
System.out.println("Hello Stan! I am a java application.");
}
}
Compile with:
javac Hello.java
Run with:
Make sure to get the caps right. 'java Hello' is not the same as 'java hello'.java Hello
If you get an error about not finding the class definition (NoClassDefFoundError), check and make sure the class path is set.
If you get this error with the message 'wrong name:' than make sure the name at the command line matches the capitalization in the code.
No comments:
Post a Comment