Hi,
I am trying to put some java files into a package however it is causing
me problems.
I have 4 JAVA Files called Node, Tree, Coalesce and Utilities. When I
put them into a package (called webb.tree) and compile them, they
compile but when I try to run the class with the main function in I get
this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Coalesce
(wrong name:
webb/tree/Coalesce)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
However if i simply remove from each of the 4 files the line "package
webb.tree;" they compile and run fine. What am I doing wrong with the
packages?
Thanks,
Alex
Joe - 23 Jun 2006 17:34 GMT
Hi Alex,
Do the class files exist in the webb/tree/ directory?
> Hi,
>
[quoted text clipped - 28 lines]
>
> Alex
Paul Hamaker - 23 Jun 2006 21:49 GMT
You run it like this :
java webb.tree.Coalesce
from the directory where the webb directory is in ?
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com
Alex - 26 Jun 2006 11:42 GMT
That seems to work! Thanks :)
> You run it like this :
> java webb.tree.Coalesce
> from the directory where the webb directory is in ?
> --------------------
> Paul Hamaker, SEMM, teaching ICT since 1987
> http://javalessons.com