Re: How to include *.class file with package in CLASSPATH?
- From: CHAFIK Wassime <wassimec@xxxxxxxx>
- Date: Mon, 28 Apr 2008 17:12:48 +0200
Ulf Meinhardt wrote:
Assume I have an already compiled java class in the following location:
D:\java\output\aaa\bbb\ccc\myclass.class
myclass.java contains the following package information:
package aaa.bbb.ccc;
The current path in the command prompt is
D:\java>
I want to compile another java class test.java which uses the class myclass e.g. in a statement like
myclass dummy = new myclass();
But when I enter a statement like:
javac -cp D:\java\output\aaa\bbb\ccc;%CLASSPATH% test.java
then the compiler complains that he cannot find myclass:
test.java:22: cannot access myclass
bad class file: D:\java\output\aaa\bbb\ccc\myclass.class
class file contains wrong class: aaa.bbb.ccc.myclass
Please remove or make sure it appears in the correct subdirectory of the classpath.
myclass dummy = new myclass();
^
1 error
Why?
I added D:\java\output\aaa\bbb\ccc to the CLASSPATH. Shouldn't that be sufficient?
Ulf
sure you didn't forgot
import aaa.bbb.ccc.myclass; //you should really name it MyClass
in the test.java
and then no need to add something to the classpath if test.class and the "aaa" folder are both in the same folder "output" in your case maybe
the classloader knows that his looking for "myclass.class" under aaa/bbbb/ccc/ :-)
hope that helps
.
- Prev by Date: Re: How to include *.class file with package in CLASSPATH?
- Next by Date: Re: Is there really no wildcard adding for "jar -cvf my.jar classes\*.class" ?
- Previous by thread: Re: How to include *.class file with package in CLASSPATH?
- Next by thread: Re: How to include *.class file with package in CLASSPATH?
- Index(es):
Relevant Pages
|