0
votes

I made a very simple applet viewer in NetBeans. Then I made a HTML file to call that ".class" file. Both .class and HTML files are stored in the same folder. But once I run the HTML file (in my local host) in my web browser (I tried with all common browser), it can't display the applet. It shows the error that I attached.

[NOTE: I also tried to upload the files in my webhosting service, in public domain, but it shows the same error.]

    /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package stringpractice;
import java.awt.*;
import java.applet.*;
import javax.swing.*;

/**
 *
 * @author 
 */
public class Applet extends JApplet {


    public void paint(Graphics g){
        super.paint(g);
        System.out.println();
        g.drawString("                                      Hello", 50, 50);

    }


}

.HTML:

    <html>
<title>Applet Viewer</title>
<body>
<applet code="Applet.class" width="300" height="300">


</applet> 


</body>



</html>

enter image description here

1

1 Answers

0
votes

By Default Unsigned applet is blocked by browsers.

To run them go to control panel > java > security

set security level to Medium.

And Click on OK. That's all. :)

enter image description here

Or to sign applet follow this url