开发者

Adding a Third Party Library to Java Applet

I have a Java Applet that needs a 3rd party library, but how do I add the jar to the classpath and reference it to the Java Applet?

My th开发者_C百科ird party library is org.apache.commons.lang.StringUtils


Do you want to embed your applet into a website / HTML with the applet tag?

<applet code="de.package.AppletClass" 
archive="apache-commons-lang.jar">
</applet>

Deploying With the Applet Tag

To compile it in console use:

javac -classpath C:\dev\YourClass.java C:\dev\3thParty.jar

Compiling the Example Programs


Put the other jars in the Class-Path property in the manifest.mf and build an index to the other jars so that the loader won't have to download a jar unless it really needs it.

Alternatively, you can mention the jars in the archive tag. In archive tag you can add multiple jars: archive="MyJar.jar,JarFile1.jar,JarFile2.jar"

So your archive attribute will be like this archive="YourProject.jar,commons-lang-2.1.jar" (Remember that you have to put commons-lang-2.1.jar with YourProject.jar in the same dir on your server.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜