Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To Compile If I Have To Set Two Classpath?

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic