java - NoClassDefFoundError on Hello World -
i trying run simple program , running errors. made simple helloworld java program, , unable run terminal on mac. have check make sure classpath set properly, , confused why not running.
here program:
public class hello { public static void main(string[] args) { system.out.println("hello, world"); } }
here terminal commands:
last login: thu may 2 12:01:50 on ttys000 172-26-125-179:~ rohan$ cd /users/rohan/desktop 172-26-125-179:desktop rohan$ ls hello.java 172-26-125-179:desktop rohan$ echo $classpath 172-26-125-179:desktop rohan$ export classpath=/users/rohan/desktop 172-26-125-179:desktop rohan$ echo $classpath /users/rohan/desktop 172-26-125-179:desktop rohan$ java hello.java exception in thread "main" java.lang.noclassdeffounderror: hello/java caused by: java.lang.classnotfoundexception: hello.java @ java.net.urlclassloader$1.run(urlclassloader.java:202) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:190) @ java.lang.classloader.loadclass(classloader.java:306) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301) @ java.lang.classloader.loadclass(classloader.java:247) 172-26-125-179:desktop rohan$
any thoughts appreciated! update ignore prior case, better view of problem:
last login: thu may 2 13:05:17 on ttys000 172-26-125-179:~ rohan$ cd /users/rohan/dropbox/current/ds/lab6 172-26-125-179:lab6 rohan$ ls hello.java 172-26-125-179:lab6 rohan$ cat hello.java public class hello { public static void main(string[] args) { system.out.println("hi"); } } 172-26-125-179:lab6 rohan$ echo $classpath 172-26-125-179:lab6 rohan$ export classpath=/users/rohan/dropbox/current/ds/lab6 172-26-125-179:lab6 rohan$ echo $classpath /users/rohan/dropbox/current/ds/lab6 172-26-125-179:lab6 rohan$ javac hello.java 172-26-125-179:lab6 rohan$ java hello.class exception in thread "main" java.lang.noclassdeffounderror: hello/class caused by: java.lang.classnotfoundexception: hello.class @ java.net.urlclassloader$1.run(urlclassloader.java:202) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:190) @ java.lang.classloader.loadclass(classloader.java:306) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301) @ java.lang.classloader.loadclass(classloader.java:247) 172-26-125-179:lab6 rohan$
try:
$ javac hello.java
$ java hello
Comments
Post a Comment