0

I am trying to embed applet into an html page and view it in a browser, but i am unable to view it in any of the browsers. (Firefox, Chrome, Edge, Internet Explorer are the browsers i have checked, and also i have enabled the java applets in all of the above.)

Below is my code for applet.java file.

import java.applet.Applet;
 import java.awt.Graphics;

 public class MyApplet extends Applet {
     @Override
     public void paint(Graphics g) {
         g.drawString("Hello applet!", 50, 25);
     }
 }

Below is the code for html file.

<html>
<head>
    <title>First Applet</title>
</head>
<body>
    <p>This is my first applet.</p>
        <embed code="MyApplet.class" 
            codebase="."
            type="application/x-java-applet;version=1.8">
            <noembed>
                No Java Support.
            </noembed>
        </embed>
</body></html>

.class file, .java file and .html files are all in the same folder.

Harsh Patel
  • 6,334
  • 10
  • 40
  • 73
  • 1
    Are Java applets still supported by modern browsers? – Robby Cornelissen Jan 04 '18 at 05:10
  • 1
    [Oracle reveals Java Applet API deprecation plan](https://www.theregister.co.uk/2016/08/24/oracle_reveals_java_applet_api_deprecation_plan/), [Why applets in JDK 9 are deprecated?](https://stackoverflow.com/questions/45535112/why-applets-in-jdk-9-are-deprecated), [The clock is ticking: The Java browser plugin will be deprecated soon](https://jaxenter.com/clock-ticking-java-browser-plugin-will-deprecated-soon-131546.html) – MadProgrammer Jan 04 '18 at 05:18
  • [Oracle's finally killing its terrible Java browser plugin](https://www.theverge.com/2016/1/28/10858250/oracle-java-plugin-deprecation-jdk-9), [JDK 9 and the Java Plugin](https://java.com/en/download/faq/jdk9_plugin.xml) – MadProgrammer Jan 04 '18 at 05:18
  • 1
    The fact is, like Flash, Java Applets are dead technology, which most browsers are not actively disabling or refusing to support ... and to be honest, good riddance – MadProgrammer Jan 04 '18 at 05:20
  • 1
    @MadProgrammer "good riddance" Hear, hear. Though it was the security holes continually reintroduced into plug-ins that likely caused the browser makes to decide to remove support, a rich client Java applet in a thin client web page was always a quirky mix that barely worked. – Andrew Thompson Jan 05 '18 at 03:52
  • 1
    @AndrewThompson Every meeting I was ever in - manager/client "I have a great idea, lets make it an applet!"; me - Hands in resignation – MadProgrammer Jan 05 '18 at 03:56

1 Answers1

0

Modern Browsers does not support java applets; as per below post on official Java website:

https://www.java.com/en/download/faq/chrome.xml

The Java Plugin for web browsers relies on the cross-platform plugin architecture NPAPI, which had been supported by all major web browsers for over a decade. Google's Chrome version 45 and above have dropped support for NPAPI, and therefore Java Plugin do not work on these browsers anymore.

Also, for edge, this stackover flow post indicates the same...

Bharat Vasant
  • 850
  • 3
  • 12
  • 46