Shared Account
Shared Account

Reputation: 93

Adding Java to Electron apps

I'm building a browser using Electron, and I want to add Java to it. So, for example, if I added this code to a webpage that is running in my browser:

    <applet width="854" height="480" title="Java" codebase="/game/" code="net.minecraft.Launcher" archive="https://s3.amazonaws.com/MinecraftDownload/launcher/MinecraftLauncher.jar?v=1321653290000">
      <param name="_cx" value="22595">
      <param name="_cy" value="12700">
      <param name="separate_jvm" value="true">
      <param name="java_arguments" value="-Xmx1024M -Xms1024M -Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false">
      <param name="userName" value="jordsta95">
      <param name="latestVersion" value="1321653290000">
      <param name="downloadTicket" value="f8ce233fd9e42d50504a790ac4af9580">
      <param name="sessionId" value="8103497761488968768">
    </applet>

it would run.

app.commandLine.appendSwitch('--enable-npapi');

I've aleardy tried the code above. But <applet> still does nothing when loaded...

Upvotes: 1

Views: 1548

Answers (1)

razki
razki

Reputation: 1229

Unfortunately there is a reason this wont work.

This would require the Java NPAPI plugin to be installed. This plugin was discontinued in Java 9, and browser engines no longer support NPAPI plugins, and as Electron runs on Chromium, there is no out of the box way way to do this.

You can check this out on the java website: https://java.com/en/download/help/enable_browser.xml

From a quick skim on github I was able to find this repo: https://github.com/jreznot/electron-java-app

But it seems to be modified heavily.

Upvotes: 2

Related Questions