简体   繁体   中英

How to use libraries with an Java applet?

The reason I have come here today is because I am experiencing difficulty running my Java applet. The applet of concern uses an external library and runs fine in the IDE; but, will not run properly in the web browser.

Specifically, it will successfully launch and features non-reliant on the library will run fine; but, when using a feature of the library, the applet does nothing.

The library I am using is contained in jgraphx.jar. Here is the source code for my HTML file, test.html:

 <HTML>
 <HEAD>
 <TITLE>Test Applet</TITLE>
 </HEAD>
 <BODY>
 Here's my first Java Applet: <BR><BR>

 <applet width="1050" height="550" archive="OAS.jar,lib/jgraphx.jar"
        code="com.OAS.OAS" />

 </BODY>
 </HTML> 

In the same directory I have test.html, OAS.jar, and a folder called lib. Inside lib is jgraphx.jar.

Inside OAS.jar are two folders, COM and META-INF. Inside META-INF is a file named MANIFEST.MF. It contains

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.7.0_07-b11 (Oracle Corporation)
Class-Path: lib/jgraphx.jar

The file structure and manifest files were automatically generated by Netbeans. I've done a lot of research and tried many different things and in my latest attempt I decided just to let the IDE handle as much as it can.

The reason I suspect that the problem is from the library is because in the beginning, the applet would not run on the webpage at all and gave me a message about being unable to access the library. After some tweaking, it now runs; but, features requiring the external library appear to not be working.

Can anybody help with my problem? Is it an issue with the HTML or the manifest files? Is it something else entirely? Any advice would be greatly appreciated.

If you want to run your Applet into Browser than you must have to signed your JAR file first. Here is the reference for more details:

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

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