用jdk1.2执行java程序,javac通过了,但java总是执行不了,是因为什么?(错误提示为——Exception in thread "main" java.lang.NoClassDefFoundError:Helloworld/class)
NOTICE: when you run a java class, do not use "java Hello.class", instead, use "java Hello". Because "." is expained as package separater.
How is a java class called? first the jvm search the classpath, then the codebase, just like when running a program in dos it search the path. then, it add the package to the classpath or codebase and invoke the class. for example:
current classpath set to d:\java, and the command-line like "java examples.test.TestJava", the package sentence in your TestJava.java should be:
package examples.test;
and there should be a dir structure like this:
d:\java\examples\testand your TestJava.java and TestJava.class should be in this dir.