CLASSPATH vs java.ext.dirs?

Java.ext. Dir has a very specific use: it's used to specify where the extension mechanism loads classes from. Its used to add functionality to the JRE or to other libraries (such as JAI).

It's not meant as a general-purpose class-loading mechanism.

Java.ext. Dir has a very specific use: it's used to specify where the extension mechanism loads classes from. Its used to add functionality to the JRE or to other libraries (such as JAI).

It's not meant as a general-purpose class-loading mechanism. Use the wildcard character * instead. It was introduced in Java 6, so many people still don't know it's possible.

Thanks for that. One other thing I was thiking about was if I use either (probably wrongly) java.ext. Dirs or specify classpath using wildcard.Is it any different from naming them one by one?

Maybe the order can matter sometimes? – Jan Zyka Feb 18 at 10:14 One point against importing 'every Jar in a directory' is that if the directory contains 1500 Jars and the app. Requires only 2 of those, the JRE might have to search a great many Jars before it discovers a class or resource.

I do not see the great benefit of using wildcards in class-paths (even if an app. Uses 50 Jars). – Andrew Thompson Feb 18 at 12:20 Thanks for opinion.

But as I described above, my lib directory contains only the jars really needed, no more no less. I don't want to hardcode them into the script since the jar versions may changed. Would you suggest then to let maven generate the script for me with the jars being hardcoded in the script?

– Jan Zyka Feb 18 at 12:45.

A big problem with putting things in the lib. Ext directory is that different applications may require different versions of libraries, and those may well conflict with one another. Think of the old DLL hell from the Windows 3 days (if you remember those) when a similar situation developed when many if not most software developers placed shared libraries in the Windows/System directory because they're picked up automatically from there rather than include them with their applications and loading them explicitly.

What you want instead is to have a separate classpath for every application (so no system level classpath! ), set in its startup script, and pointing to only those jar files and class directories applicable for that specific application. That way several applications with conflicting library needs can be launched side by side without interfering with each others functionality.

The same is true even more if you're a developer, where you don't want any outside libraries interfering with your application while testing it. And there's another thing: if you're developing and using the lib/ext trick (or a system level classpath), how can you ever be sure that the application you're going to ship ships with the correct libraries? If you forget to include on in your installer or installation package, you'd never notice because it's on your machine in a shared location.

But the customer, who doesn't have that library, would get runtime errors and shortly be on the phone demanding support (and possibly a refund, and giving you bad reviews in the press for shipping a defective product).

Agree, I wrote that the application is run via a script which sets the classpath or java.ext. Dirs just for the app. The lib folder (as mentioned above) is part of the app so only the jars needed for the app are there.So no shared libraries and no shared classpaths here.

– Jan Zyka Feb 18 at 10:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions