0

Problem & Background-info

I'm trying to develop an application for a client of mine on Fiverr and he requested I use the applet library I have never used before. I did a little tutorial and I keep getting an apple not initialized error and I have no idea how to fix it.

##Goal

I just want java to display the thing I drew on the applet viewer without throwing an error.

Code

import java.awt. *;
import java.applet. *;

//<applet code = app height=400 width = 400></applet>
public class app extends Applet {
    public void paint(Graphics g){
        g.drawOval(40,40,120,150);
        g.drawOval(57, 75, 30, 20);
        g.drawOval(110, 75, 30, 20);
        g.fillOval(68, 81, 10, 10);
        g.fillOval(121, 81, 10, 10);
        g.drawOval(85, 100, 30, 10);
        g.fillArc(60, 125, 80, 40, 180, 180);
        g.drawOval(25, 92, 15, 30);
        g.drawOval(160, 92, 15, 30);

    }
}

Terminal

danielcaminero@Macbook-Air-3 src % javac app.java       
Note: app.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
danielcaminero@Macbook-Air-3 src % appletviewer app.java
2022-05-29 09:28:18.859 appletviewer[18039:277277] CoreText note: Client requested name ".HelveticaNeueDeskInterface-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2022-05-29 09:28:18.859 appletviewer[18039:277277] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2022-05-29 09:28:19.126 appletviewer[18039:277277] CoreText note: Client requested name ".HelveticaNeueDeskInterface-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2022-05-29 09:28:19.127 appletviewer[18039:277277] CoreText note: Client requested name ".HelveticaNeueDeskInterface-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
java.lang.UnsupportedClassVersionError: app has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:217)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:627)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:799)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:728)
        at sun.applet.AppletPanel.run(AppletPanel.java:378)
        at java.lang.Thread.run(Thread.java:748)
Caminero
  • 265
  • 3
  • 19
  • *and he requested I use the applet library* Run away. Applets have been obsolete for decades, and no modern browser will run them (since March 2019 they've been REMOVED from Java). – Elliott Frisch May 29 '22 at 13:32
  • @ElliottFrisch I’m using the applet viewer – Caminero May 29 '22 at 13:39
  • You are using Java 16 (March 2021) to compile. As I already said, applets were removed in March 2019. The version of applet viewer you are running is from Java 8. That is why it does not work. But as I also already said, Applets have been obsolete for decades and you should not waste your time on this project. It will not end well. Because it can't end well. Applets are **dead**. – Elliott Frisch May 29 '22 at 13:44
  • @ElliottFrisch my client just wants me to draw a face, so if I switch to Java 8 it will work with applets viewer? – Caminero May 29 '22 at 13:47
  • IDK. I haven't programmed an Applet in over a decade. But this particular error is because you ***already*** are using the Java 8 applet viewer. There isn't a newer one. Because applet support was totally removed from the language. – Elliott Frisch May 29 '22 at 13:51
  • Your code might just as well be shown in a `JPanel` in an application – g00se May 30 '22 at 10:51

0 Answers0