Reputation: 3998
I am trying to make a simple Applet, and it is proving far more challenging than I expected.
I have the following, very basic applet:
import java.applet.*;
import java.awt.*;
public class HelloWorldApplet extends Applet
{
public void paint (Graphics g)
{
g.drawString ("Hello World", 25, 50);
}
}
created in notepad and saved as:
HelloWorldApplet.java
then in the same folder I have the following HTML file:
<html>
<title>The Hello, World Applet</title>
<hr>
<applet code="HelloWorldApplet.class" width="320" height="120">
If your browser was Java-enabled, a "Hello, World"
message would appear here.
</applet>
<hr>
</html>
created in notepad and saved as:
HelloWorldApplet.html
I am getting the following error when trying to load the page:
ClassNotFoundException
HellowWorldApplet.class
Java is installed on the machine and from all the tutorials and reading I have done, everything is exactly correct.
Any ideas??
Upvotes: 1
Views: 2428
Reputation: 1157
Embed the following code in the applet file as a multiline comment.
Eg:
/*
<applet code="HelloWorldApplet.class" width="320" height="120"></applet>
*/
save this as "HelloWorldApplet.html"
Compile using javac
command
javac HelloWorldApplet.java
for Run the program using appletviewer
command
appletviewer HelloWorldApplet.html
Upvotes: 3