First Applet not running on browsers
I am writing my first applet. I have read some tutorials but I cant get it to run in my browser (it runs in the applet viewer though). Please be detailed in your answer because this is my first applet.
This is the process I am following and the code:
Using eclipse I created a project. Then right click on it to create a class (as in java applicatons). But i replaced the code in the class file for:
package pkgs;
import java.awt.*;
import java.applet.*;
public class FirstApplet extends Applet{
public void paint(Graphics g){
g.drawString("Simple applet", 20, 20);
}
}
Then I run it as an applet and it worked in the applet viewer.
Then I created a jsp page calling the applet:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>V2</title>
</head>
<body>
<applet code="FirstApplet" width = "260"height = "200"></applet>
</body>
</html>
Then I run it again and "Export" it to .WAR in my tomcat root directory. I am calling the page but it says:
load: class FirstApplet not found.
java.lang.ClassNotFoundException: FirstApplet
The file FirstApplet.class is in the WEB-INF folder, under classes and the package name folder.
I even tried to copy paste the .class file to the same directory as the .jsp file but no luck.
What am I missing.
Thanks in advance for your help.
Still not working! any suggestions?
The jar file is a compressed file, also the applet runs in the viewer but now in the browser. I also tried the other suggestion of copy pasting the class file to the same directory without luck.
If the jar file needs to be generated as well as the war files for web projects that include applets could you please provide the steps to follow in eclipse to generate the compress file which could be used online?
All I can see is the generation of a compress file (jar).
I also tried to add codebase keyword in the <applet> tag, no luck either.
Any other suggestions?