What are the repercussions of using "java.ext.dirs" together with "-classpath"?
-
"java.ext.dirs" appear to work just like -classpath. I know of an application that uses them together in including libs. An observation is that you should not include the same jar with java.ext.dirs and -classpath. What could be the reason behind this?
-
Answer:
The problem is one of versions. With CLASSPATH, you specify exactly what files are going to be included. With java.ext.dirs, it includes everything in the directory. There is some set of rules by which the classloader decides which jar files reference which other jar files. If you have the same file in both places, it's very easy for the two to get out of synch, and you can end up with incompatibilities leading to crashes. The java.ext.dirs mechanism makes it easy to accidentally include multiple versions of the same file, since it takes everything in the directory. Generally, you use CLASSPATH for your program itself, and you use java.ext.dirs for plugins and extensions that are discovered from and loaded by your program. You can use java.ext.dirs alone, and it can be easier, but on a large-scale production environment it gets fraught.
Joshua Engel at Quora Visit the source
Other answers
In addition, another complication is that java.ext.dirs uses a different ClassLoader from the classpath set through -classpath: http://docs.oracle.com/javase/tutorial/ext/basics/load.html This gets confusing especially if the code in the jars - especially libraries - do explicit classloading.
Miguel Paraz
Related Q & A:
- How to upload file to google cloud storage using Java?Best solution by Stack Overflow
- How to Implement Gateway Service something similar to Oracle API gateway Using Java and Java based Open Source frameworks only?Best solution by Quora
- how can I listen for database changes using java?Best solution by Stack Overflow
- How to search for a particular string in a text file using java?Best solution by Stack Overflow
- How do you program using Java?Best solution by wikihow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.