[英]How does HTML java applet finds its .jar?
I have this code: 我有以下代码:
document.write("<APPLET CODE='com/synergex/My.class' ARCHIVE='toc2.jar' ");
When my "toc2.jar" is in the same folder as the HTML - all works fine. 当我的“ toc2.jar”与HTML位于同一文件夹中时-一切正常。
But when I put "toc2.jar" in another folder ("C:\\MyJars"), I get ClassNotFoundException
. 但是,当我将“ toc2.jar”放在另一个文件夹(“ C:\\ MyJars”)中时,出现ClassNotFoundException
。
How can I "tell" the browser where to look for jars? 我如何“告诉”浏览器在哪里寻找罐子?
I tried to add "C:\\MyJars" or "C:\\MyJars\\toc2.jar" to my CLASSPATH
env variable, but it did not work. 我试图将“ C:\\ MyJars”或“ C:\\ MyJars \\ toc2.jar”添加到我的CLASSPATH
env变量中,但是没有用。
You might be able to redirect the code base using an HTML base
element . 您可能可以使用HTML base
元素重定向代码库。
For example, given the following
BASE
declaration andA
declaration: 例如,给定以下BASE
声明和A
声明:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Our Products</TITLE>
<BASE href="http://www.aviary.com/products/intro.html">
</HEAD>
<BODY>
<P>Have you seen our <A href="../cages/birds.gif">Bird Cages</A>?
</BODY>
</HTML>
the relative URI
"../cages/birds.gif"
would resolve to: 相对URI"../cages/birds.gif"
将解析为:
http://www.aviary.com/cages/birds.gif
If not, there are only 2 options. 如果没有,则只有2个选项。
codebase='../path/'
immediately after it, to tell the JRE to wherever the Jar is located. 假定脚本的唯一部分是您不能更改的,请在该脚本后立即添加codebase='../path/'
,以告知JRE Jar所在的位置。 As an aside: 作为旁白:
CODE='com/synergex/My.class'
Should be: 应该:
CODE='com.synergex.My'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.