Forums Register Login

Package woes

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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"
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 634 times.
Similar Threads
How do I upload large files?
Number of connections grows forever
Cannot find bean under name ....
Anonymous constructors
Comparing directories - revisited
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 02:24:57.