hi there
i am using osx 10.4.11. i am using the head first java book to do my first java application. it seems i am having a very common problem with an error of:
Exception in thread "main" java.lang.NoClassDefFoundError: Beersong (wrong name: chap01/BeerSong)
here is my terminal interaction:
-----------------
rich-Computer:~/Desktop/head first java/chap01 rich$ javac BeerSong.java
richs-Computer:~/Desktop/head first java/chap01 rich$ ls
BeerSong.class BeerSong2.java IfTest.java PhraseOMatic.java
BeerSong.java HelloWorld.class PhraseOMatic.class helloworld.java
rich-Computer:~/Desktop/head first java/chap01 rich$ java Beersong
Exception in thread "main" java.lang.NoClassDefFoundError: Beersong (wrong name: chap01/BeerSong)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
rich-Computer:~/Desktop/head first java/chap01 rich$
----------
as you can tell, my java program (BeerSong.java) compiles fine but i get this error. i am using the default settings within OSX for java development so nothing has changed. i have also ensured that the compiled class file of BeerSong.class is local to the BeerSong.java file. should this not work? what am i doing wrong or how do i get this working?
thanks
i am using osx 10.4.11. i am using the head first java book to do my first java application. it seems i am having a very common problem with an error of:
Exception in thread "main" java.lang.NoClassDefFoundError: Beersong (wrong name: chap01/BeerSong)
here is my terminal interaction:
-----------------
rich-Computer:~/Desktop/head first java/chap01 rich$ javac BeerSong.java
richs-Computer:~/Desktop/head first java/chap01 rich$ ls
BeerSong.class BeerSong2.java IfTest.java PhraseOMatic.java
BeerSong.java HelloWorld.class PhraseOMatic.class helloworld.java
rich-Computer:~/Desktop/head first java/chap01 rich$ java Beersong
Exception in thread "main" java.lang.NoClassDefFoundError: Beersong (wrong name: chap01/BeerSong)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
rich-Computer:~/Desktop/head first java/chap01 rich$
----------
as you can tell, my java program (BeerSong.java) compiles fine but i get this error. i am using the default settings within OSX for java development so nothing has changed. i have also ensured that the compiled class file of BeerSong.class is local to the BeerSong.java file. should this not work? what am i doing wrong or how do i get this working?
thanks