How to disable the loading of installed extensions?

Hi

As you may know, when you run a Java application, the JVM uses at least 3 classloaders: the bootstrap classloader, the extension classloader and the application classloader (which loads the classes in the classpath). When using JNLP in an applet or in an application, the JVM uses one more classloader. It is even more complicated when using a servlet container or a module system.

This is what I mean by “installed extensions”:
http://docs.oracle.com/javase/tutorial/ext/basics/install.html

I sometimes use Java3D 1.6.0 and I often use JogAmp (especially JOGL and JOAL). Some developers complain about Apple going on shipping an obsolete version of Java3D as an extension which is loaded by default before the version available in the classpath, it obviously causes some conflicts.

As far as I know, there is a property allowing to override the set of directories used to find the extensions to load, this property is called “java.ext.dirs”. I’ve looked at the source code of OpenJDK:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/misc/Launcher.java#166

Setting it to “” should solve my problem, the obsolete version of Java3D shouldn’t be picked if there is no directory denoted in java.ext.dirs. However, a developer under OS X goes on complaining that it doesn’t work but as he hasn’t given me any information about the version of OS X and the JVM, I don’t know what to do. I can try to reproduce his “bug” on a Mac but if it reproducible only with a particular version of Java and/or OS X, I won’t succeed. Please can some Mac OS X users confirm whether this property is honored with OpenJDK and/or Oracle Java? As far as I know, it can be set as a JVM option in command line, in a JNLP file or just very early in the program by calling System.setProperty(“java.ext.dirs”, “”).

What you do in this situation, is ignore them, until they give you the information you’ve asked for.

Cas :slight_smile:

I can do it this time but this isn’t something new.

If anybody can help me with a recent Mac, let me know.

Write your own classloader.

I already tried that but then, I need several implementations, depending on which parent classloader is in use. I’m not sure I can instantiate the application classloader with the system classloader as a parent and use it as is. When using JNLP, the “lowest” classloader is a parent of the application classloader not in sun.misc.Launcher which drives this even more complicated. That’s why I would be grateful if someone could confirm whether or not setting java.ext.dirs to “” works under Mac OS X 10.9.

You don’t have to defer to a parent.

java.ext.dirs is taken into account if and only if it is set very early as a VM option or as a property in a JNLP file. If you use a “runnable” JAR, rather call Runtime.exec to run a VM with the proper parameters or use a script. Someone else tested on Mavericks. I’ll update my Java3D tutorial soon.