Java beginners are often confused about how to configure the Java development environment. There are many friends in the forum to ask questions about JDK configuration, especially after configuration, compiling Java files, always encounters such a problem, error tips are:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-1998 Microsoft Corp.
C: /> javac helloworld.java
C: /> Java HelloWorld
Exception in thread "main" java.lang.noclassdeffounderror: HelloWorld
C: />
The above is an error message, the source program is as follows:
Class helloworld {
Public static void main (String [] args) {
// display "Hello World!"
System.out.println ("Hello World!");
}
}
How to translate How to run Exception in Thread "Main" java.lang.noclassdeffounderror: HelloWorld ??????? /
For the above questions, everyone has consistently solving the path to the directory where the helloWorld.java file is located, such as: set classpath =% classpath%;.; ... (here you should pay attention to ".;", After a while, we do a test to see what it means. I tried it, it seems that I can't do it, I don't know if I am not configured. As for the netizens who give this question, there is no specific practice, I don't know. So I did an attempt.
I use WIN2000 JDK1.30, download J2SDK1_3_0-win.exe in java.sun.com, then click Install, install the default path of the system, install it to C: disk, namely: C: / JDK130. Installation completion requires a configuration environment, which involves three parameters: Path, ClassPath, Java_Home. In my computer - "Properties -" Advanced - "Environment Variables, add these three variables, their values are:
Name = value
Java_Home = C: / JDK130 (installation path)
Classpath = .; c: /jdk13/lib/tools.jar; c: /jdk13/lib/dt.jar; C: / JDK13 / bin
PATH = C: / JDK13 / bin;
Then determine it.
Note: ClassPath is used to indicate all directories where all classes used to reference, which allow users to put their own classes in different directories, but should let JDK compilation tools know there. E.g:
Set classpath = .; c: /jdk13/lib/tools.jar; c: /jdk13/lib/dt.jar; c: / jdk13 / bin
The first dot in the command indicates the current working directory of the ClassPath. This dot is very useful, when you are not willing to enter the full current directory path, you can use it instead, the Java program allows you to do this.
In D: New Sub-directory Java, write a java file, name is Hello.java, enter the DOS mode, go to the directory D: / Java, then knock Javac Hello.java, compile. You can then use the Java Hello to run the generated Class file, no problem, and the result is normal. If we join: package hello in the Hello.java file:, then compile, no errors, run when we run: Exception in thread "main" java.lang.noclassdeffounderror: hello (WRONG "
Hello / Hello)
At java.lang.classloader.defineclass0 (Native Method)
At java.lang.classloader.defineclass (ClassLoader.java: 486)
At java.security.secureclassloader.defineClass (SecureClassLoader).
1)
At java.net.urlclassloader.defineclass (urlclassloader.java:248)
AT java.net.urlclassloader.access0 (urlclassloader.java: 56)
AT java.net.urlclassloader.run (urlclassloader.java: 195)
AT java.security.accessController.doprivileged (Native Method)
AT java.net.urlclassloader.findclass (urlclassloader.java: 188)
At java.lang.classloader.loadclass (ClassLoader.java: 297)
At sun.misc.launcher $ AppClassLoader.loadClass (launcher.java: 286)
At java.lang.classloader.loadclass (ClassLoader.java: 253)
At java.lang.classloader.loadclassinternal (ClassLoader.java: 313)
At this time, we should compile, you should: javac -d. Hello.java will generate a new subdirectory in the current directory, the directory name is Hello.
We can use two ways to run compilation files, in the current directory, knock in: Java Hello / Hello or Java Hello Hello, so we can see the results.