The Artima Developer Community
Sponsored Link

Java Answers Forum
package and import

2 replies on 1 page. Most recent reply: Oct 9, 2003 10:00 AM by rassuls

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
rassuls

Posts: 10
Nickname: rassuls
Registered: Mar, 2003

package and import Posted: Oct 8, 2003 9:11 PM
Reply to this message Reply
Advertisement
I have two java classes A.java & B.java in C:\test\pack folder as:

package pack;
public class A
{
}

and

package pack;
import pack.*;
public class B
{
public static void main(String[] args)
{
System.out.println("Test");
}
}

and the classpath=.;C:\test;

Both files compile successfully but when I run B I get the following error messages:

Exception in thread "main" java.lang.NoClassDefFoundError: B (wrong name: pack/B)
at java.lang.ClassLoader.defineClass0(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)

Any help?
Thank you
RS


Rahul

Posts: 52
Nickname: wildhorse
Registered: Oct, 2002

Re: package and import Posted: Oct 8, 2003 9:57 PM
Reply to this message Reply
Use the qualified name of the class, because it now belongs to a package:

C:\test>java pack.B

rassuls

Posts: 10
Nickname: rassuls
Registered: Mar, 2003

Re: package and import Posted: Oct 9, 2003 10:00 AM
Reply to this message Reply
Thank you, it worked. Where would I learn about these things? Is this information under classpath readings or JVM invocation from the command line?
Thanks again

Flat View: This topic has 2 replies on 1 page
Topic: Transaction attributes at  EJB Level Previous Topic   Next Topic Topic: LinkedList

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use