Reputation: 2967
I have a very simple java applet, that Im using source code from the docs.oracle(http://docs.oracle.com/javase/tutorial/deployment/applet/getStarted.html) site that should work, and it works in eclipse just fine, it's getting it onto the page that's the problem. The file is on a localhost server at localhost/applet/applet.html and I have the file JavaQuiz.jar in the same directory. My html file is as follows.
<hmtl>
<applet codebase="localhost/applet/"
code = 'JavaQuiz.jar'
archive = 'JavaQuiz.jar'
width = 300
height = 300 />
</html>
Is there something Im missing? Or need to change? I look forward to any help that could be given, and please try to explain it more than telling me the answer so I can learn. :D
This is what is in the java colsole Java Plug-in 10.5.1.255 Using JRE version 1.7.0_05-b05 Java HotSpot(TM) Client VM
c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache
plugin2manager.parentwindowDispose
The Chrome developer help thing doesn't show any problems. And when I click details on the applet it just says classnotfounfexception: JavaQuiz
Upvotes: 1
Views: 1387
Reputation: 168845
http://localhost/applet/JavaQuiz.jar
will not work at time of deployment.
<html>
<applet
codebase="."
archive="JavaQuiz.jar"
code="JavaQuiz"
width = 300
height = 300 >
</applet>
</html>
Since the code base points to the 'current directory' this will work for the applet while on localhost as well as deployed live.
Points, some of which have already been mentioned:
.class
on the end.</applet>
to close the element.codebase="."
is redundant. It should also work without it.Upvotes: 1
Reputation: 12328
<html>
<applet
archive="http://localhost/applet/JavaQuiz.jar"
code="JavaQuiz.class"
width = 300
height = 300 />
</html>
I think the biggest problem is not having the http://
I'm not entirely sure about the other parameters. Play around with that.
So in your case change codebase="localhost/applet/"
to codebase="http://localhost/applet/"
Upvotes: 2
Reputation: 1891
Also you should have an eye on localhost...
this means that the j.jar is located in a folder called localhost in the same directory that the html is in. Is that true? Or do you mean http://localhost:80/applet/
or /applet/
Upvotes: 2
Reputation: 5045
The mandatory "code" attribute (which is missing in your example) should point to the class which you intend to run (the one extending JApplet). Something like:
<html>
<applet codebase="localhost/applet/" code="yourpackage.YourApplet.class"
code = 'JavaQuiz.jar'
archive = 'JavaQuiz.jar'
width = 300
height = 300 />
</html>
Upvotes: 1
Reputation: 83125
The code
attribute should point to a fully qualified class name, not to a jar.
Upvotes: 2