islandcraz
islandcraz

Reputation: 31

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 third party library is org.apache.commons.lang.StringUtils

Upvotes: 3

Views: 8029

Answers (2)

zacheusz
zacheusz

Reputation: 8842

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.)

Upvotes: 4

timaschew
timaschew

Reputation: 16602

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

Upvotes: 4

Related Questions