aspose file tools*
The moose likes Beginning Java and the fly likes Package woes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package woes" Watch "Package woes" New topic
Author

Package woes

Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
I have 2 classes(A, B) in a package. -->lev1.lev2.lev3;

So, I created 3 directories lev1, lev2 and lev3 and placed my classes
in lev3.

package lev1.lev2.lev3;
class A {
public static void main(String[] args) {}
}

package lev1.lev2.lev3;
class B {
}

Now when I run A.class, I get the followign error:
java.lang.NoClassDefFoundError: lev1/lev2/lev3/A

Please help!!

-Cathy.
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
To run a class defined in a package, the root directory must be included in your classpath. For example, if you have the following structure:
Then the root directory "projects" must be in your classpath and you need to execute the program using the fully-qualified name:
e.g. "java lev1.lev2.lev3.A"


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package woes
 
Similar Threads
How do I upload large files?
Comparing directories - revisited
Anonymous constructors
Number of connections grows forever
Cannot find bean under name ....