• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Where to put jar files

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just started with Java, using 1.4.2, in windows. I have a couple of questions about where 3rd party jar files should be placed.

I am using iText, a set of java classes to create PDF files. Now to get my programs to compile, I placed the itext-1.3.jar file in the same folder as my java source file. Now I know that is definitely not the place to really put it. Should I create a seperate folder solely for itext, or do I put the jar file under the jre folder under the j2sdk folder, or some other place.

2nd Question: To get my java code to compile, I copied servlet.jar to my local folder, as it does not seem to be in the jre path. Is servlet.jar part of j2SDK1.4.2, and I just wasn't setting it up correctly. Or did I have to download it, and where should it be placed, in which folder?

Thank you

Andrew
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a lib folder and place my .jars in there. (C:\user\java\lib\ is where mine is...) Then, I set the CLASSPATH to include the .jars in that directory. (Note that you have to specify each .jar explicitely in the CLASSPATH; specifying the lib directory is not sufficient.)

As far as your second questions, no, servlet.jar is not part of the J2SDK -- it's part of the J2EESDK. If you need to use it in a non-J2EE application, then yes, you need to include it manually.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people like to put their jar files in C:\java\jre\lib\ext

jar files in there are automatically added to the classpath.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you're using for development in terms of IDE. Assuming you are using and IDE this is what I do.

Create a lib directory inside the project directory, by sructure looks like:


In the lib directory goes the jar I'm using, if a jar requires other jars I create a subdir for that (just for me to keep things straight in case I want to add/remove/change something).

During development let the IDE handle the classpath issues for compilation. When you get ready to release create a manifest file setting all the jars in the lib directory. When you do a release you can create a jar from source and put it and the lib directory into a zip. The user then only has to unzip and doubleclick the jar. Of course there are more elegant, though more difficult, installation methods.

If you are using a text editor dealing with the classpath becomes more tedious.

I tend to stay away from putting jars into the java\jre\lib\ext folder. It keep me from running into the problem of 'works on my dev machine, but not anywhere else'.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic