This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JAR Files and Class Path

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this
javac -classpath "c:\program files\tomcat\lib\servlet-api.jar" myJavaSource.java
 
munna next
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's working. Thanks for the tip.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!