Adding a Third Party Library to Java Applet

前端 未结 2 729
一个人的身影
一个人的身影 2020-12-06 21:14

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

相关标签:
2条回答
  • 2020-12-06 21:51

    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

    0 讨论(0)
  • 2020-12-06 21:57

    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 讨论(0)
提交回复
热议问题