Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: How to incl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 8 Topic 16026 of 16078
Post > Topic >>

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

by Lew <lew@[EMAIL PROTECTED] > Apr 26, 2008 at 10:03 PM

Lion-O wrote:
> On 2008-04-26, Ulf Meinhardt <ulf2m@[EMAIL PROTECTED]
> 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




 8 Posts in Topic:
How to include *.class file with package in CLASSPATH?
ulf2m@[EMAIL PROTECTED]   2008-04-26 15:17:50 
Re: How to include *.class file with package in CLASSPATH?
Lion-O <nosp@[EMAIL PR  2008-04-26 10:26:02 
Re: How to include *.class file with package in CLASSPATH?
Lew <lew@[EMAIL PROTEC  2008-04-26 22:03:53 
Re: How to include *.class file with package in CLASSPATH?
=?ISO-8859-1?Q?Arne_Vajh=  2008-04-26 11:33:48 
Re: How to include *.class file with package in CLASSPATH?
Roedy Green <see_websi  2008-04-27 10:44:42 
Re: How to include *.class file with package in CLASSPATH?
Joshua Cranmer <Pidgeo  2008-04-27 22:16:50 
Re: How to include *.class file with package in CLASSPATH?
CHAFIK Wassime <wassim  2008-04-28 17:12:48 
Re: How to include *.class file with package in CLASSPATH?
evan <evan.e.thomas@[E  2008-04-29 16:08:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 23:43:02 CDT 2008.