Re: "java Hello" Problem
buts101 schrieb:
->java Hello
Then i get this error message:
->Exception in thread "main" java.lang.NoClassDefFoundError: hello
Lothar Leidner wrote:
You named your class "Hello" (not ("hello").
Now, let's assume you do this:
java Hello
and see this:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
That would indicate that you have not given 'java' the classpath information
it needs. The classpath is a list of directories that are at the root of your
class directory hierarchies, and of individual JAR files. It follows the same
syntax as other path variables in your operating system, such as PATH.
(Note: the classpath does not include directories that contain JARs, only
directory tree roots that contain .class files and references to the JAR files
themselves. For example, assuming UNIX,
"/somedirectory/classroot:/someotherdirectory/path/necessary.jar".)
What is your current working directory (cwd) when you execute "java Hello"?
You likely will need to specify:
java -cp directoryAtRootOfYourClassTree Hello
which, if your cwd is the directory where your default-package classes reside,
would be:
java -cp . Hello
for example.
-Lew