Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is putting external jars in the JAVA_HOME/lib/ext directory a bad thing?

Tags:

java

jar

We have an application which runs in a JRE environment. The application uses some external jars and we have been putting them in the JAVA_HOME/lib/ext folder. This has worked for us for years but recently a new programmer joined our team and seems emphatic that this is some how a bad thing to do. I can't understand why and I'm trying to do some research before I dig further with this developer. Is there something I'm missing here?

like image 418
Elliott Avatar asked Jan 15 '10 01:01

Elliott


People also ask

Where should I put JAR files?

The best way is to add the jar to your project is as follows: Create a folder called lib in your project folder. copy all the jar files you need to this folder . Refresh your project in eclipse.

What is ext directory in Java?

ext. dirs referred to a single directory, but as of Java 6 it is a list of directories (like CLASSPATH) that specifies the locations in which extensions are searched for. The first element of the path is always the lib/ext directory of the JRE. The second element is a directory outside of the JRE.

Where do we put the JAR files that we don't have downloaded with us?

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.


1 Answers

Yes - it's a bad thing. Think about it: the application depends on the JRE and some extra jars. What if you update the JRE? Then you have to remember to copy the files into the new JRE. What if you need to set up the application on a new system? You have to copy the application there, and then also remember to copy the external jars into the JRE on that system.

Both those issues wouldn't be an issue at all if you just package the application properly together with the external jars it needs. If you don't see this, then maybe it's not an issue at all. But you should still be grateful for the new guy for sharing his opinion.

like image 191
weiji Avatar answered Sep 21 '22 00:09

weiji