Reputation: 3454
Environment: Ubuntu 12.04, JRE 1.6.0
In my zsh, even a simple hello.java
cannot run normally.
It's ok when compiled it with javac
, but then typed java hello
:
Exception in thread "main" java.lang.NoClassDefFoundError: hello
Caused by: java.lang.ClassNotFoundException: hello
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: hello. Program will exit.
Upvotes: 0
Views: 264
Reputation: 40318
The class name is helloworld
and you are trying to say java hello
. Check it once
Upvotes: 0
Reputation: 453
Try java helloworld. By default, Java will compile with the same name as the file.
so javac helloworld.java outputs helloworld.class, which is what you need to access to run the bytecode.
Upvotes: 0
Reputation: 17622
Your class name seems to be helloworld
and you are trying to say java hello
(hence JVM tries to find a class named hello
which doesnt exist)
please try java -classpath . helloworld
Upvotes: 4