Package Problems

A

Alex

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
 
P

Paul Hamaker

You run it like this :
java webb.tree.Coalesce
from the directory where the webb directory is in ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top