File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes How To Compile If I Have To Set Two Classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How To Compile If I Have To Set Two Classpath?" Watch "How To Compile If I Have To Set Two Classpath?" New topic
Author

How To Compile If I Have To Set Two Classpath?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
My java files are in the C:\TOMCATHOME\webapps\MyApp\WEB-INF\src\java\org\apache\example folder
Those java files import lots of JARs in the C:\TOMCATHOME\webapps\MyApp\WEB-INF\lib folder.
When I try to compile my java files,
1. set the classpath:
C:\>set CLASSPATH=C:\TOMCATHOME\webapps\MyApp\WEB-INF\src\java;%CLASSPATH%
2. change to the directory where my java files are:
C:\>cd C:\TOMCATHOME\webapps\MyApp\WEB-INF\src\java\org\apache\example
3. compile my java files
But, the compiler does not know all the required JARs are in the C:\TOMCATHOME\webapps\MyApp\WEB-INF\lib folder. How do I put the JARs in the classpath? I have tried to compile in different ways but did not succeed.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

you need to construct a classpath argument.

-classpath=.;
C:\TOMCATHOME\common\lib\servlet.jar;
C:\TOMCATHOME\webapps\MyApp\WEB-INF\lib\foo.jar;
C:\TOMCATHOME\webapps\MyApp\WEB-INF\lib\foo2.jar;
C:\TOMCATHOME\webapps\MyApp\WEB-INF\lib\foo3.jar;

etc, etc....

Note... do NOT put a trailing semicolon after the last entry and this is all on one line (without spaces or hard returns)
This is why most people use either an IDE, or ANT
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Thanks, Mike. It is exactly what I need to know. I want to work out an application without the assistance of the ANT or any IDE at least once.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To Compile If I Have To Set Two Classpath?
 
Similar Threads
Really Need Help. Java Compiler Cannot Find the Required JAR File in the Classpath
Servlet in Package Issue
Compiling stubs fails
Compiling custom imports
Setting the classpath to struts jars to compile my actions