How to configure JDK in Windows 2000

xiaoxiao2021-03-06  42

Java beginners are often confused about how to configure the Java development environment. There are many friends on the forum to ask questions about JDK configuration, especially after the configuration, always encounter such a problem, error tips: 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!");}} Translation For Exception in Thread "Main" java.lang.noclassdeffounderror: HelloWorld ??????? / For the above questions, everyone has consistently solved the path to the directory where the helloWorld.java file is located in the parameter classpath, such as: Set classpath =% classpath%;.; ... (here you should pay attention to ".;", after a while we do a test to see what is meaningful. 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 determined. 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. For example: set classpath = .; c: /jdk13/lib/Tools.jar; c: /jdk13/lib/dt.jar; c: / jdk13 / bin; command in the command indicates the current working directory of 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;, then compile, no error, run when we run: Exception in thread "main" java.lang.noclassdefounderror: hello (Wronghello / 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 like this: javac -d. Hello.java will be currently current A new subdirectory is generated in the directory, and 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.