Is there any alternative to applet viewer in JDK12?
I am new to Java and I tried to add AWT checkbox in Java It runs fine in JDK 1.8, but not running in JDK12.
I searched over internet and found that the applet viewer is Deprecated. (The Applet API is deprecated, no replacement) on the official oracle's help web page.
I search about this problem and got no satisfying answers so I posted here...
import java.applet
import java.awt.*;
/*
<applet code="CreateCheckBox" width=200 height=200>
</applet>
*/
public class CreateCheckBox extends Applet{
public void init(){
Checkbox checkBox1 = new Checkbox();
checkBox1.setLabel("My Checkbox 1");
Checkbox checkbox2 = new Checkbox("My Checkbox 2");
add(checkBox1);
add(checkbox2);
}
}
It should work in JDK12 because it runs in JDK1.8.
There is officially no way to run applets on Java 11 or later:
appletviewer
application has been removed.The java.applet.*
classes that applets depend on have been removed.
Correction : They haven't done this yet, but I expect they will soon.
Applets should be treated as dead technology.
You could conceivably implement your own version of the appletviewer
classes and put them together with your applet code into a JAR file. It should work. However, it is a bad idea. The primary use-case for applets was to embed Java in websites, and that won't work because modern browsers no longer support Java plugins. (Indeed, many recent browsers actively block Java plugins!)
The best thing to do is to rewrite applets using different technology, depending on what they do:
You said:
It should work in JDK12 because it runs in JDK1.8.
This is not logically correct.