Where to put the external jars? [duplicate]

If you're wanting to include a JAR file to your Eclipse project, you would generally create a 'lib' folder inside the project folder, and put the file in there. You then need to tell eclipse to include it in your class path so your code will compile and run inside eclipse.

To do that:
- Go into the properties of your project
- Select 'Java Build Path' in the left hand column
- Select the 'Libraries' tab in the centre part of the window
- Click the Add JARs button - this will give you a list of your projects in eclipse - expand your project and into the lib folder - your jar will be there.
- Select the JAR, click OK, and OK again out of the properties window.

Your code will now compile and run.


put it in your jre/lib/ext folder

everything said about the classpath is true, but this is a consistent and sensible place for it to live.

you can find out your jre folder by looking at the JAVA_HOME environment variable on Windows.


It doesn't matter too much where you put it, but you need to configure your other non-Eclipse project to put the external jars in its classpath - or use the extensions directory mechanism, if you must. (That's easier, but making it explicit is arguably better.)


Simon's answer seems to be the best but a bit outdated now. Have googled this Oracle doc Installed extensions .

As of Java 6, extension JAR files may also be placed in a location that is independent of any particular JRE, so that extensions can be shared by all JREs that are installed on a system.

It says that for Windows you should place your extensions here %SystemRoot%\Sun\Java\lib\ext .