Make applet run outside editor
Hello,
My applet runs in my editor, but it does not work to make it run on a normal web page. This is the HTML file I wrote with a reference to the java applet on my harddrive. It gives an error that it cant find the java file:
<html>
<head>
<title>blackjack</title>
</head>
<body>
<h1>blackjack</h1>
<hr>
<applet code="D:/java/mijnprogs/blackjack5.class" width="300" height="300">
</applet>
<hr>
</body>
</html>
What am I doing wrong?
Re: Make applet run outside editor
Quote:
<applet code="D:/java/mijnprogs/blackjack5.class" width="300" height="300">
I think the issue you are having is the absolute address of "D:/java/mijnprogs/blackjack5.class." Try changing it to something relative like, if the html file is located in the java folder, make the code attribute be mijnprogs/blackjack5.class. That would be my first attempt.
Re: Make applet run outside editor
Thanks for your reply, a relative reference does indeed work. But isn't there be a possibility for an absolute reference?
Re: Make applet run outside editor
Note that the reference needs to be a URL, not a file name; that relative file path also happens to be relative URL but your absolute file path isn't a URL; read the URL class API documentation for details.
kind regards,
Jos
Re: Make applet run outside editor
Look at the HTML doc for the <Applet tag. The code= attribute names the class, not a path. There is another attribute that gives the path to the class file's location. Something like base or code base.