Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Package Problems

Thread view: 
Alex - 23 Jun 2006 14:45 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.