I am working on a homework assignment that is requiring me to create a basic applet that runs in a browser. I already know that the applets have been deprecated, so I know that this probably will not work with current browsers.
This is my Java code:
import java.applet.Applet;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JLabel;
public class SimpleJavaApplet extends JApplet{
public void paint(Graphics g) {
g.drawString("Hello World!", 80, 80);
g.drawString("Blah!", 100, 100);
}
}
This is my HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>A Short Test</title>
</head>
<body>
<title>Test Applet</title>
<applet code="SimpleJavaApplet.class" width = "200" height = "50">
</applet>
<h1>Test Test Test</h1>
</body>
</html>
What I was hoping would happen is that a browser would launch and it would show up with the HTML, but the only think I have been able to get to run is the AppletViewer. I am wondering if this is even possible anymore and if I should just let my professor know that.
Any ideas will be greatly appreciated.
Edit: Just to make things clearer, I am trying to run this code so it runs through a browser and not just the AppletViewer.
Neither Chrome nor Firefox are no longer supported NPAPI.
Java and Firefox Browser
Java and Google Chrome Browser
Finally Java Applets and Java Web start were completely removed from Oracle Java 11 SE.
Java 11 SE Release Notes
and
So if you're using Java 9 or below the appletviewer is available or if you able to download and install an ancient Chrome (less than 45) you can run that applet but Java 11 or above there is no alternative solution just the migration.