简体   繁体   English

如何在Java中使用CLASSPATH环境变量指定依赖于applet的jar

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

I have an applet and it is dependant on some test.jar. 我有一个applet,它依赖于一些test.jar。 So , I have added this jar in CLASSPATH environmental variable. 因此,我在CLASSPATH环境变量中添加了这个jar。 classpath /dir/test.jar 类路径/dir/test.jar

But this jar is not recognized by the applet and getting ClassNotFound exception for the class inside this test.jar. 但是小程序无法识别此jar,并且此test.jar中的类正在获取ClassNotFound异常。

But after adding test.jar in archive attribute, everything is working fine. 但是在archive属性中添加了test.jar之后,一切工作正常。 Why applet is not recognizing classpath?. 为什么applet无法识别类路径? Is there any way to specify applet dependencies with out archive attribute?. 有没有办法指定没有存档属性的applet依赖项?

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. 应在清单的Class-Path条目中指定applet的依赖JAR或实际上部署为JAR文件的任何Java应用程序的依赖JAR。

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. 如果通过java -jar运行任何Java应用程序,则将忽略命令行或CLASSPATH上指定的任何类路径,并且仅观察清单Class-Path You don't state how exactly you're running your applet, but presumably the same applies. 您没有说明运行小程序的精确程度,但是大概也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM