I'm trying to insert a Java applet on HTML page.
This is my body HTML:
<body>
<object data="applets/pac/Teste.class" width="300" height="250">
</object>
This text appears on the right side of the applet
<br clear="all"/>
This text appears bellow the applet
</body>
And this is my Teste
class:
package pac;
import java.awt.Graphics;
public class Teste extends java.applet.Applet {
private static final long serialVersionUID = 1L;
public void paint(Graphics g){
g.drawString("Teste de Applet!",20,55);
}
}
The path is correct, I'm using Tomcat server and Eclipse. When I go to the index.html, my browser downloads the Teste.class
so I tried to solve it by using type="application/x-java-applet"
on the object and it no longer tries to download but also the applet doesn't appear. It doesn't give me any Class not found error. I've tried embed and it's the same thing.
I'm learning Java by a book but it uses codebase
on the param
and it is obsolete.
I'm just a beginner, I don't know if I should use applets. Thank you.