This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes compileing with .jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compileing with .jar file" Watch "compileing with .jar file" New topic
Author

compileing with .jar file

Eung maeng
Ranch Hand

Joined: Feb 10, 2002
Posts: 68
Does anyone explain to me how to compile or whether it is possible instead of import com.vertex....etc;

thanks,
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You'll always need the "import" whether you use JAR files or not.


[My Blog]
All roads lead to JavaRanch
Eung maeng
Ranch Hand

Joined: Feb 10, 2002
Posts: 68
thanks, do i need to extract .jar for compiling the source if .jar contains a classes.

thanks a lot,
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

No, just inlude the JAR in your classpath.
For example javac -cp c:/myjars/bob.jar;. Hello.java
Eung maeng
Ranch Hand

Joined: Feb 10, 2002
Posts: 68
thanks,

I tried to compile a source on dos prompt with your command like javac -cp.... -CP option is not valid for compiler.

anotherone,
e.g,
a test.java source is in c:\APP\PGM\
and
import B.UTIL.Iaddress;
import B.UTIL.Ilookup;
....

jar is in c:\lib\utility.jar what contains for Iaddress and Ilookup etc..

In this case, where I need to compile and how , what I have to do for compile.

Please let me know if it's not good exampe for your answer.

Regards,
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
use -cp for java command is fine
However, you must spell it out -classpath for javac command

Who knows why? But we have to follow it.

here is the official help from the commands
Eung maeng
Ranch Hand

Joined: Feb 10, 2002
Posts: 68
thanks, -cp =-classpath
Eung maeng
Ranch Hand

Joined: Feb 10, 2002
Posts: 68
hi,
How do I define multiple .jar for compile?

thanks a lot,
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
semicolon ; separated path for Windows
Use colon : for unix
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Pau, sorry for the wrong compiler argument.
 
jQuery in Action, 2nd edition
 
subject: compileing with .jar file
 
Similar Threads
Iimplicit cast
Running code
is khalid wrong?
can we create a class named Object?
Doubt in annotations.