| Author |
About Package file inter-access
|
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
two file lie on the same dir(f:\javapackage). the content of bbb.java file is: the content of aaa.java file is: When I compile the aaa.java file, I get the following message:
---------- Compile (javac.exe) ---------- aaa.java:5: cannot resolve symbol symbol : class bbb location: class javapackage.aaa bbb b; ^ 1 error
I remember that classes in the same package can inter-access. Why can the aaa class not get the bbb class in this situation? What's wrong with it? [ October 22, 2002: Message edited by: Mikey Chen ] [ October 22, 2002: Message edited by: Mikey Chen ]
|
Rome was not built in a day.
|
 |
William Barnes
Ranch Hand
Joined: Mar 16, 2001
Posts: 984
|
|
Try compiling the bbb.java first or try compiling with a wildcard.
|
Please ignore post, I have no idea what I am talking about.
|
 |
Rene Larsen
Ranch Hand
Joined: Oct 12, 2001
Posts: 1179
|
|
Put a .(dot) in your CLASSPATH Rene
|
Regards, Rene Larsen
Dropbox Invite
|
 |
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
Originally posted by William Barnes: Try compiling the bbb.java first or try compiling with a wildcard.
1.I have compiled bbb.java but get the same result. 2.Using "javac *.java" goes well. However, if there have many files and only one file has been modified, I think recompiling all files will get low performance.
Originally posted by Rene Larsen: Put a .(dot) in your CLASSPATH Rene
I put a .(dot) in my CLASSPATH, but get same result.
|
 |
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
My compile environment maybe go ill. I use also get the same result. Can you tell me what's the problem?
|
 |
Paulo Salgado
Ranch Hand
Joined: Jan 18, 2002
Posts: 98
|
|
Since you have the in your classes and the classpath set to f:\javapackage, javac is probably trying to find your classes at f:\javapackage\javapackage. Try to change you classpath to f:\ only or remove the package statements from both classes to use the default package (the classes directory).
|
 |
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
Paulo Salgado: Thanks! I add ".\.." to my CLASSPATH. All go well. Thanks William and Rene for your replies.
|
 |
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
Hi all, there has another problem. I have compiled the two files successfully. But I can not excute the aaa.class file. After typing following command I got the following error message.
---------- Run (java.exe) ---------- java.lang.NoClassDefFoundError: aaa (wrong name: javapackage/aaa) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:250) at java.net.URLClassLoader.access$100(URLClassLoader.java:54) at java.net.URLClassLoader$1.run(URLClassLoader.java:193) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:299) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265) at java.lang.ClassLoader.loadClass(ClassLoader.java:255) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315) Exception in thread "main" Output completed (0 sec consumed) - Normal Termination
Why can VM not find the class file? Thanks!
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Make your working directory the parent directory of the package. So, try: f:> java javapackage.aaa What did you do to do to compile the files successfully?
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Mikey Chen
Greenhorn
Joined: Jul 12, 2002
Posts: 29
|
|
Originally posted by Dirk Schreckmann: Make your working directory the parent directory of the package. So, try: f:> java javapackage.aaa What did you do to do to compile the files successfully?
Thanks! I execute it successfully. ps. I can't understand the question of you. Maybe the answer lies what I have posted above.
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Nevermind. You already answered it. Thanks. I add ".\.." to my CLASSPATH. All go well.
|
 |
 |
|
|
subject: About Package file inter-access
|
|
|