简体   繁体   English

试图通过html文件加载java applet

[英]Trying to load java applet via html file

Directory is like so: 目录是这样的:

test.html
blah
hmmm

Inside "blah" we have all the applet files, including blahBlah.class. 在“blah”里面我们有所有的applet文件,包括blahBlah.class。 Inside "hmmm" are a few more more class files that were taken from a library or something, they are used by the project also. 在“hmmm”里面是从库或其他东西中获取的更多类文件,它们也被项目使用。

I write in test.html... 我在test.html中写...

<applet name="blah" code="/blahBlah.class" codebase="blah"></applet>

(along with every other variation I could think of) (以及我能想到的所有其他变体)

Farthest I've gotten is: 我得到的最远的是:

java.lang.NoClassDefFoundError: blahBlah (wrong name: blah/blahBlah)

Now inside blahBlah.java, we have: 现在在blahBlah.java中,我们具有:

package blah;

I'm not sure if it's related. 我不确定它是否相关。

Also wondering if it may be necessary to place the project in a jar file and set the archive attribute of the applet? 还想知道是否有必要将项目放在jar文件中并设置applet的archive属性?

The real files are not blah and blahBlah, but I've replaced the names faithfully. 真实的文件不是blah和blahBlah,但我忠实地替换了这些名字。

java.lang.NoClassDefFoundError: blahBlah (wrong name: blah/blahBlah) java.lang.NoClassDefFoundError:blahBlah(错误名称:blah / blahBlah)

This basically means that it's been executed as 这基本上意味着它已经被执行为

java blahBlah

instead of 代替

java blah.blahBlah

In other words, your code attribtue is wrong. 换句话说,您的code属性是错误的。 It has to be 它一定要是

<applet name="blah" code="blah/blahBlah.class" />

or just by FQN (see also Andrew's comment) 或仅通过FQN(另请参阅安德鲁的评论)

<applet name="blah" code="blah.blahBlah" />

The codebase defaults to the current folder, which is fine in this case, so it's removed. codebase默认为当前文件夹,在这种情况下很好,所以它被删除了。 An alternative is to put it in another folder, such as /applet or something. 一种替代方法是将其放在另一个文件夹中,例如/applet或其他内容。 You should at least not use a package folder as code base, but instead the package root. 您至少不应使用软件包文件夹作为代码库,而应使用软件包根目录。

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

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