Class JarLoader
- java.lang.Object
-
- de.julielab.java.utilities.classpath.JarLoader
-
public class JarLoader extends Object
This class adds JAR files to the classpath at runtime. There are two different ways chosen depending on the JVM version, up to 8 or beginning with 9. The Java 9 approach requires an instrumentation agent which is located atAgent. The agent must be included in a JAR that registers it by the Agent-Class property of its MANIFEST.MF file. This class can either used inside the julielab-java-utilities JAR file directly, which has the Agent-Class property set for its manifest. When building a fat JAR, e.g. with the Maven assembly or Maven shadow plugins, containing this class, the fat JAR must have the property itself.
-
-
Constructor Summary
Constructors Constructor Description JarLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddJarToClassPath(File jarFile)static voidloadLibraryWithURLClassloader(File jar)https://stackoverflow.com/questions/27187566/load-jar-dynamically-at-runtime
-
-
-
Method Detail
-
addJarToClassPath
public static void addJarToClassPath(File jarFile)
-
loadLibraryWithURLClassloader
public static void loadLibraryWithURLClassloader(File jar)
https://stackoverflow.com/questions/27187566/load-jar-dynamically-at-runtimeWARNING: This only works up to Java 8. Beginning with Java 9, the system classloader is not an URLClassLoader any more. Adds the supplied Java Archive library to java.class.path. This is benign if the library is already loaded.
-
-