File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 14688
    
  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: 14688
    
  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: 14688
    
  16

Pau, sorry for the wrong compiler argument.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compileing with .jar file