aspose file tools*
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 Spring in Action 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
Author

JAR Files and Class Path

munna next
Ranch Hand

Joined: Sep 28, 2004
Posts: 46
Hi,
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 myJavaSource.java

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)
Like,

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

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

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" myJavaSource.java
munna next
Ranch Hand

Joined: Sep 28, 2004
Posts: 46
It's working. Thanks for the tip.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAR Files and Class Path