This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Classpath in Command line  RSS feed

 
Ranch Hand
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I was going through Head First Servlets book and found myself stuck in the BeerSelect.java example.

=======
PROBLEM
=======

To compile the servlet following code is being used:
% javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

I am using Windows XP and my Tomcat directory's path is this:
C:/Program Files/Apache Software Foundation/Tomcat 5.5/common/lib;


So I am using this code in the command prompt to compile, but it generates an error:
C:\beerV1>javac -classpath /Program Files/Apache Software Foundation/Tomcat 5.5/common/lib//servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

Error:
javac: invalid flag: Files/Apache
Usage: javac <options> <source files>
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set the classpath for your program. For eg.

c:> set classpath=.;Here provide the path of your servlet-api-jar; %z%;
 
Nelo Angelo
Ranch Hand
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies, but I want to know how the above given code can be modified to be used in Windows. The compound statement that sets the classpath as well as compiles the code.
 
Marshal
Posts: 59779
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would appear to have misread the previous post, which uses a Windows® idiom.
Yoiur question is not at all clear. Do you mean this
javac -cp .;c:\MyFolder\MyOtherFolder\MyJar.jar MyClass.java
 
Greenhorn
Posts: 8
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


shankh
 
Nelo Angelo
Ranch Hand
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply guys, the problem is resolved.

I used the following code:

C:\beerV1>javac -cp C:\Tomcat_6.0\lib\servlet-api.jar; -d classes src/com/example/web/BeerSelect.java
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!