Re: How to include *.class file with package in CLASSPATH?
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sat, 26 Apr 2008 22:03:53 -0400
Lion-O wrote:
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 just compiling without setting any classpath, or, if your classpath
contains specific settings try: javac -cp .;%CLASSPATH test.java
Arne gave the correct answer, which this wasn't. He also suggested to follow the coding conventions, which have us use upper-case letters to begin class names (and lower-case ones to begin variable and method names), and camel case thereafter.
Additionally, having the word "class" in a class name is silly.
CLASSPATH is a blunt tool. Normally one shouldn't use it, at least not much. Use the -cp option completely.
To run Test (correcting the class name), and assuming a dependency on MyExample in package aaa.bbb.ccc (directory d:\java\output\aaa\bbb\ccc\) and Test in package xxx.yyy.zzz, and the current working directory d:\work\,
java -cp D:\java\output xxx.yyy.zzz.Test
Of course, Test.java will start off with these directives:
package xxx.yyy.zzz;
import aaa.bbb.ccc.MyExample;
--
Lew
.
- References:
- Prev by Date: Re: how to return Comparator values
- Next by Date: Re: how to return Comparator values
- 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
|
|