简体   繁体   中英

How to specify applet dependent jars using CLASSPATH environmental variable in java

I have an applet and it is dependant on some test.jar. So , I have added this jar in CLASSPATH environmental variable. classpath /dir/test.jar

But this jar is not recognized by the applet and getting ClassNotFound exception for the class inside this test.jar.

But after adding test.jar in archive attribute, everything is working fine. Why applet is not recognizing classpath?. Is there any way to specify applet dependencies with out archive attribute?.

The dependent JARs of an applet or indeed of any Java application deployed as a JAR file should be specified in the Class-Path entry of the Manifest.

If you run any Java application via java -jar , any classpath specified on the command line or the CLASSPATH is ignored and only the Manifest Class-Path is observed. You don't state how exactly you're running your applet, but presumably the same applies.

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