Adding Library to JRE

ε祈祈猫儿з 提交于 2020-01-06 02:30:12

问题


I work in an enterprise setting where we use a Java applet as part of an internal application. A Java class used by the applet is included in the JDK that we use to develop, but not in the JRE that end users have on their computers. As such, every time the applet is loaded, the users seem to be requesting the class from the server.

Is there a way to "add on" this class to the JRE? Either as a JAR or otherwise?


回答1:


The public API of JDKs from different vendors should be identical. So either you are talking about different versions or you are using "internal API" of the JDK.

The simplest way to ensure compatibility is relying on the "smaller" set as a development environment and adding everything else as external libraries. This way you can just ship what is needed as part of your applet (just repackage everything you need in one fat-jar).

If you are "in control" of your user base: Just ship "your" JDK or ship additional libraries in the ext directory of the JDK/JRE (https://docs.oracle.com/javase/tutorial/ext/basics/install.html) of the user.

You cannot add something to a JRE from an applet, this defeats the idea of an applet running in a sandbox.




回答2:


As such, every time the applet is loaded, the users seem to be requesting the class from the server.

Appearances can be deceptive. The JRE will report downloading from the server even if the file is locally cached. This is for security reasons.




回答3:


You can put the classes packed in a JAR file on $JRE/lib/ext. The classes will be acessible to any Java App where uses that JRE.

Read it, for more details: https://docs.oracle.com/javase/tutorial/ext/basics/install.html



来源:https://stackoverflow.com/questions/29850917/adding-library-to-jre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!