Re: How to include *.class file with package in CLASSPATH?



On 2008-04-26, Ulf Meinhardt <ulf2m@xxxxxxxxx> wrote:

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>

---<CUT

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:

Try thinking of packages being directories when you're working on the
commandline. You already seem to be doing that since you've setup a directory
structure aaa\bbb\ccc. Now, in order to find the classes in the package the
compiler expects to be able and access a directory structure aaa\bbb\ccc which
then contains myclass.class.

But your classpath doesn't have that, it only points to the directory where
myclass.class resides but that directory doesn't contain the actual directory
structure.

Try just compiling without setting any classpath, or, if your classpath
contains specific settings try: javac -cp .;%CLASSPATH test.java


Groetjes, Peter

--
..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc

.



Relevant Pages

  • Re: about classpath setting
    ... >>> the program at dos prompt in the directory of package name i am ... >>> bin directory i am getting the error class not found.According to ... >> You do not set the CLASSPATH environment variable at all. ... This tells the compiler that you are going to be using the ...
    (comp.lang.java.help)
  • Re: Linux java - package does not exist
    ... which is why javac can't find it. ... the OP did state that they had an 'avi' directory under the cwd ... The main program should not be in the default package if they're ... the classpath, and that is the default classpath, so it might not be ...
    (comp.lang.java.help)
  • Re: Where did javac find some other class?
    ... me the FQN of the class of which it claims that it is lacking ... but also from where on the classpath it really got ... I'd recommend that you ditch the classpath altogether and use -cp on the command line, setting it appropriately for each step when javac is invoked. ... Thus, you don't have to worry about the compiler getting confused with some other class when compiling your stuff, you just set the local path you need for your stuff. ...
    (comp.lang.java.programmer)
  • Re: import package
    ... I'm trying to import a package stored in a file "jacob.jar" by: ... says the compiler. ... You need to put "c:\program files\java\classes\jacob.jar" in CLASSPATH. ...
    (comp.lang.java.programmer)
  • Re: package junit.framework does not exist
    ... not find the junit package. ... From Eclipse, the project compile fine, but from the command line, I ... I have included junit.jar in the classpath, ...
    (comp.lang.java.programmer)