简体   繁体   中英

How to access the jar placed inside lib\ext directory in Eclipse?

I've made a jar library and places it inside jdk and jre's ext directory to check for installed extension scenario in Java.

Now when I a trying to create a Java project in eclipse and try to use the jar files classes or use the library, I am not able to access but those jar files are visible under Java PRoject jre system library in ECLIPSE.

  1. Are the extension classes loaded when you run something outside of Eclipse? For example you can try the following command in a terminal to check if a class from the extension can be found:

     javap name.of.ExtensionClass
  2. When you run your program from Eclipse, are you sure that you use the JRE that has the extension installed?

You probably will have to specifically reference the jar in Eclipse. The colleciton of JARs that come with the JRE are also included in the manifest file so that the runtime knows which files to request be loaded. Since your jar is not in the manifest, it will not be loaded automatically.

An alternative might be to repackage a JRE with an updated manifest that refers to your extension jar.

After adding to JAVA_HOME/lib/ext file or java.ext.dirs system property, Don't Run the jar file ,it won't. but Run the class with package name ,it will.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM