Old posting, maybe helpful

jabber (jabber)
<本文发表于: 相约加拿大:枫下论坛 www.rolia.net/f >
Q: I am trying to learn Java. I copied a Hello.java example to C:\sources and then succeeded in compiling the course file into the class file. Then, I tried to run this example by entering "java Hello". However, I got an effor message saying "....java.lang.NoClassDefFoundError:...". What's wrong?

A: Very probably, your Windows envirenment variable CLASSPATH does not include ".", --- the current directory. To execute your command "java Hello", Java Virtual Machine needs to search the class file Hello.class according to CLASSPATH. If it fails to find the class file, it will complain by throwing the message you cited. For a Java programmer, it is a good practice to include the current directory in the CLASSPATH.

To make your example work, you can reset the CLASSPATH by issuing


in the MS-DOS. The above command means to append . (the current directory) to the CLASSPATH.

Note: Windowes envirment variable should be sandwished by a pair of percentage signs (%). After you reset the CLASSPATH, you will have luck to run your example.

PATH and CLASSPATH are two most basic environment variables for Java programmers. Even seasoned Java developers can get into dark with them. A Java novice needs to make many mistakes with them before mastering them.
<本文发表于: 相约加拿大:枫下论坛 www.rolia.net/f >

2000-10-26 -04:00

回到话题: Jabber ,help me!

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT杂谈