File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes JAR Files and Class Path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAR Files and Class Path" Watch "JAR Files and Class Path" New topic

JAR Files and Class Path

munna next
Ranch Hand

Joined: Sep 28, 2004
Posts: 46
I am compiling the JAVA File which has to have classpath reference for the file servlet-api.jar.
I have this file in c:\program files\tomcat\lib\servlet-api.jar So I am compiling like

C:\javaexample> javac -classpath c:\program files\tomcat\lib\servlet-api.jar

When I execute the above statement I am getting any error "ClassNotFoundException"

But when I put the jar file in a folder which is not having space (Pl see "Program files" has space in between)

C:\javaservletsource\servlet-api.jar and compile like below

C:\javaexample> javac -classpath C:\javaservletsource\servlet-api.jar

It is getting compiled. So my question is that "Is that the referenced class or jar files should not be in a folder which is having space (like Program Files)?

Thanks for clarification on this.
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
Create a batch file that will execute the java command for you.

In that batch file, set your CLASSPATH variable.

Something like this:

That way you can add to the class path easily enough in the future.
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
Try this
javac -classpath "c:\program files\tomcat\lib\servlet-api.jar"
munna next
Ranch Hand

Joined: Sep 28, 2004
Posts: 46
It's working. Thanks for the tip.
I agree. Here's the link:
subject: JAR Files and Class Path
It's not a secret anymore!