unix - could not find the main class java error -
i having trouble not find main class error complicated program working on. eliminate possible problems decided try hello world program see if work. working on server i'm pretty sure running red hat enterprise 6. followed these steps provided bart kiers in answer this question:
- create file called helloworld.java;
- paste code posted below
- inside helloworld.java: compile executing command: javac helloworld.java in same folder helloworld.java in;
- execute code doing: java -cp . helloworld in same folder helloworld.java in.
i following error after last step:
exception in thread "main" java.lang.noclassdeffounderror: helloworld/ caused by: java.lang.classnotfoundexception: helloworld. @ java.net.urlclassloader$1.run(urlclassloader.java:217) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:205) @ java.lang.classloader.loadclass(classloader.java:321) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:294) @ java.lang.classloader.loadclass(classloader.java:266) not find main class: helloworld.. program exit.
if type java -version, version info displays, suggesting path variable set correctly. have other suggestions things might causing error? thanks!
looks putting period @ end of class name:
java -cp . helloworld.
do instead
java -cp . helloworld
Comments
Post a Comment