Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put external jars in jdk10

Tags:

java

I've been putting external jars in jre/lib/ext in JDK8 However ,when i update my jdk to jdk10,i cannot find jre sub-directory in jdk directory. So I download jre10 from Oracle and it turns out that the ext directory is missing... where should I put those external jars?

like image 659
Collen Zhou Avatar asked Jul 10 '18 08:07

Collen Zhou


People also ask

Where do I put the external jar file?

To include external JAR files, you can either: Copy all the JAR files of the external packages to the Java's Extension Directories (NOT applicable to JDK 9). For Windows, the JDK extension directory is located at " <JAVA_HOME>\jre\lib\ext " (e.g., " c:\Program Files\Java\jdk1.

Where are Java JARs stored?

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.

What is ext folder 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.


1 Answers

This is no longer supported, from Migrating to JDK 10 from JDK 8 :

Removed Extension Mechanism

In previous releases, the extension mechanism made it possible for the runtime environment to find and load extension classes without specifically naming them on the class path. Starting in JDK 9, if you need to use the extension classes, ensure that the JAR files are on the class path.

The javac compiler and java launcher will exit if the java.ext.dirs system property is set, or if the lib/ext directory exists. To additionally check the platform-specific systemwide directory, specify the -XX:+CheckEndorsedAndExtDirs command-line option. This causes the same exit behavior to occur if the directory exists and isn’t empty. The extension class loader is retained in JDK 9 (and later releases) and is specified as the platform class loader (see getPlatformClassLoader.)

like image 96
Arnaud Avatar answered Nov 10 '22 00:11

Arnaud