9

I'm using eclipse and I'm creating this java applet but I keep getting below error when I tried to run an applet. I know it's deprecated in the new version (I even tired 1.8) but is there something I can use to make it work?

Error: Could not find or load main class sun.applet.AppletViewer Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer

enter image description here

11
  • 2
    Java applets are dead. Feb 3, 2019 at 18:15
  • 4
    You are running Java 11, this does not have AppletViewer. You will have to run with an older Java.
    – greg-449
    Feb 3, 2019 at 18:21
  • 1
    So I don't need to downgrade my eclipse version, but Java? Yes? Feb 3, 2019 at 18:41
  • 2
    Yes you would have to use an older java version. Preferably Java 8 (not too old for IDEs and not too young to deny access to internal/private packages like sun.applet.AppletViewer).
    – tobain
    Feb 3, 2019 at 19:06
  • 2
    Sorry, but that doesn't wash. You (the student) are paying good money for your education. If you are being taught stuff that is out of date, then you should be asking for your money back. Because the stuff that you learn about applets won't be any help to you in getting a job. Your teacher should be teaching you to build Android apps or JavaFX. Your school needs to invest in updating its curriculum.
    – Stephen C
    Oct 2, 2019 at 11:27

2 Answers 2

12

I think you are using jdk-13. However, Applets support jdk-8 and lower.

The current solution for you would be:

  1. Install jdk-8 and open Eclipse.
  2. Go to Window -> Preferences -> Add -> next and find your jvm folder(e.g. /usr/lib/jvm).
  3. From there select jdk-8.
  4. After adding jdk-8, remove the jdk-13 from Preferences.

After everything here, it should start working. If you encounter the error

Exception in thread "main" java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper

you can simply run this command

sudo sed -i -e '/^assistive_technologies=/s/^/#/' /etc/java-*-openjdk/accessibility.properties

1

For support of Applets in Netbeans, you can edit the path to your JDK in netbeans config file which is found in /netbeans-8.2/etc/netbeans.conf. Change the line netbeans_jdkhome="" to your JDK 8 e.g netbeans_jdkhome="/usr/java/jdk1.8.0_241-amd64/"

Not the answer you're looking for? Browse other questions tagged or ask your own question.