I am having problems trying to run my applet file when I upload it on my website. It keeps giving me errors, but works perfectly fine on my computer. I am using NetBeans to create my Applets and I used the <Applet>
tag, since I remember using it and it worked. But NetBeans did state a warning message stating that the <Applet>
tag has been deprecated and advised to use <Object>
.
Now this is where it gets a little harder for me, because I do not know how to use the <Object>
tag for applets. I definitely searched for answers online. Each gives different ways of declaring it for an Applet, but none of them worked. NetBeans constantly returns a warning/error messages each time I attempted different methods stated online.
So my question would be this: how do I correctly use the <Object>
tag for a Java Applet?
After much searching, I found an example that returns no value but does not even load the Applet on my computer. The example is below: java code:
<object data="VirtualArmory.jar" type="application/x-java-applet"></object>
I have attempted both .jar and .class and the output is still the same. The Java plugin kept loading.
EDIT:
This is the error I got when I used the <Applet>
tag. But did not get any when using the developJava.js
.
java.lang.ClassNotFoundException: VirtualArmory
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
This is how I attempted the developJava.js command. Sorry since it is my first time seeing and using this command, I will tend to make a lot of mistakes.
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
codebase:'http://morganaprime.webs.com/',
code:'VirtualArmory.class',
archive:'VirtualArmory.jar',
width:710,
height:540
};
var parameters = {gunSize:16};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
I am randomly attempting what ever I can to make this work! This is the link to my testing website. website here
So my question would be this: how do I correctly use the
<Object>
tag for a Java Applet?
The correct answer is "don't use it" (or the applet
element). Instead delegate the responsibility for embedding the applet to deployJava.js
. It might look something like this.
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
codebase:'http://morganaprime.webs.com/',
code:'net.mp.eoncalculator.VirtualArmory',
archive:'VirtualArmory.jar',
width:710,
height:540
};
var parameters = {gunSize:16};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
But NetBeans did state a warning message stating that the
<Applet>
tag has been deprecated..
Only since HTML 4.01 (which was a long time ago)!
Update - working example

<html>
<body>
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
codebase:'http://morganaprime.webs.com/',
code:'net.mp.eoncalculator.VirtualArmory',
archive:'VirtualArmory.jar',
width:1000,
height:700
};
var parameters = {gunSize:16};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
</body>
</html>
来源:https://stackoverflow.com/questions/14474564/java-applet-errors-on-web-hosting-site