Adding a Third Party Library to Java Applet

islandcraz picture islandcraz · Jul 12, 2011 · Viewed 7.9k times · Source

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

Answer

timaschew picture timaschew · Jul 12, 2011

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