How do I run Java applets?

16

3

Is there a way to run a Java applet on Chrome or Firefox? I get the error message on the Java test page that Java won't run on Chrome or Firefox anymore because of the non-supported NPAPI.

I have an old set of *.class files with an .html to run it, and I just want to be able to run this applet somehow. But how?

jerrrrro

Posted 2019-01-16T15:49:31.400

Reputation: 163

Question was closed 2019-01-19T22:33:01.110

In Chrome, on Windows 10:

Some applets work using "CheerpJ Applet Runner" plugin: https://chrome.google.com/webstore/detail/cheerpj-applet-runner/bbmolahhldcbngedljfadjlognfaaein

Example: https://math.la.asu.edu/~kawski/vfa2/

Click on CheerpJ icon. Press: "Run Applets"

Wait 3 minutes, while CheerpJ dynamically converts the Applet to Javascript.

Use converted Applet/Javascript, i.e. you are not running a real Applet, but a Javascript variant which may or may not work properly.

– user19496 – 2019-05-28T16:45:26.373

Answers

21

Is there a way to run a Java applet on Chrome or Firefox?

No. Applets are no longer supported in Firefox or Chrome.

Firefox no longer provides NPAPI support (technology required for Java applets)

As of September, 2018, Firefox no longer offers a version which supports NPAPI, the technology required to run Java applets. 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. The 64 bit version of Firefox has never supported NPAPI, and Firefox version 52ESR is the last release to support the technology. It is below the security baseline, and no longer supported.

Source Java and Firefox Browser

Chrome no longer supports NPAPI (technology required for Java applets)

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.

Source Java and Google Chrome Browser


So how do I run Java applets?

Use the AppletViewer, from a JDK before Java SE 11.

The appletviewer command allows you to run applets outside of a web browser.

SYNOPSIS

appletviewer [ options ] urls ...

DESCRIPTION

The appletviewer command connects to the documents or resources designated by urls and displays each applet referenced by the documents in its own window. Note: if the documents referred to by urls do not reference any applets with the OBJECT, EMBED, or APPLET tag, then appletviewer does nothing. For details on the HTML tags that appletviewer supports, see AppletViewer Tags.

Note: The appletviewer is intended for development purposes only.

Source appletviewer - The Java Applet Viewer

Alternatively read the Oracle White Paper (pdf) Migrating from Java Applets to plugin free Java technologies, which recommends Java Web Start:

Java Web Start has been included in the Oracle JRE since 2001 and is launched automatically when a Java application using Java Web Start technology is downloaded for the first time. The conversion of an applet to a Java Web Start application provides the ability to launch and update the resulting application without relying on a web browser

See What is Java Web Start and how is it launched? for more information.

Note that both Java Applets and Java Web Start were removed completely in Java SE 11 (release September 2018). From that version on there is no (supported) way to run Applets or Web Start applications.

DavidPostill

Posted 2019-01-16T15:49:31.400

Reputation: 118 938

4So how do I run Java applets? :-) – jerrrrro – 2019-01-16T16:35:28.953

really?? that's the only way to run Java applets these days? I find it strange! – jerrrrro – 2019-01-16T17:00:00.183

3

Note even webstart is dropped in java 11 and the 'official' way is now to use j9+ modules to create 'lean' downloadable apps although j8 remains supported for 'deployment' = webstart for a few more years

– dave_thompson_085 – 2019-01-17T00:26:14.920

8@jerrrrro: apparently you missed the last decade and a half, when Java sandbox (= applet/webstart) bugs were one of the biggest and most frequent vectors for system infections and breaches. Every few weeks all the security websites announced "huge danger from browser java! remove java from all your systems NOW!", a few weeks later "okay, Sun/Oracle patched that one", a few weeks later "ANOTHER huge danger from java!". The browser makers got tired of this and removed support permanently, so Oracle made the best of it: "we didn't really want to run in browsers anymore" – dave_thompson_085 – 2019-01-17T00:32:37.123

Out of curiosity why did this happen? There's lots of other junk that simply won't go away and Java/Sun is still strong. – northerner – 2019-01-17T06:19:26.363

4@jerrrrro, also, Java applets (and Flash applets) were obsoleted by HTML5 and various WebApis, which allows actual integration into the page as a whole rather than just an embedded box with basically no legal interaction with the rest of the content. – Jan Hudec – 2019-01-17T07:06:25.577

@dave_thompson_085: Thanks for pointing out that Web Start (and Applets) were dropped in Java 11. I edited to clarify. – sleske – 2019-01-17T09:50:44.867

@jerrrrro you don't. You just don't. I won't name and shame, but in college, we had to program in assembler for a particular architecture that we emulated via java applet. I filed a complaint because of the fact that we were programming on our personal computers and the university was deliberately requiring us to install a security hole on them. That was years and years ago: even back then it was a Known Bad Thing. The unfortunate answer is that the most realistic option is to find another option or port the software. – Jared Smith – 2019-01-17T13:58:52.137

1Is using IE11 still an option on Windows? – Dan is Fiddling by Firelight – 2019-01-17T15:57:18.410

@DanNeely Yes. As this webpage from Java itself explains you just need to configure IE to enable Java applets. On the latest versions of Chrome, Firefox, and Safari, running Java applets is disabled.

– ub3rst4r – 2019-01-17T16:40:28.287

5

If you already have the files on your machine, you can try the appletviewer that (used to? still does?) ships with the JDK (Java Development Kit).

Pete Kirkham

Posted 2019-01-16T15:49:31.400

Reputation: 230