Java module compatibility?


I’m trying to create an Electron application that leverages some legacy Java code we have and can’t easily get rid of. I’m guessing many people have this challenge. This means I need to use the java module that’s available on npmjs. I could get it to work with NW.js, but I can’t seem to get it to work with Electron on Windows. Here’s what I’ve done:

  • Installed the windows-build-tools npmjs module (that in turns installs Python and the MS VS command line build).

  • Cloned the electron-quick-start and verified that it built and ran correctly on my system.

  • Installed the Java module (version 0.80) into package.json. After downloading, it did a successful build process.

  • Removed the node_modules directory and did an npm install again. Again, I can see the Java support files (.cpp) compiling as expected, with no errors.

  • Ran the electron-quick-start again, and it came up with no problems.

  • Added the line const java = require('java') to the main.js of electron-quick-start

  • When I run the sample, I see the following error:
    App threw an error during load Error: A dynamic link library (DLL) initialization routine failed. \\?\C:\devel\electron-quick-start\node_modules\java\build\Release\nodejavabridge_bindings.node at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20) at Object.Module._extensions..node (module.js:598:18) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at C:\devel\electron-quick-start\node_modules\java\lib\nodeJavaBridge.js:21:16 at Object.<anonymous> (C:\devel\electron-quick-start\node_modules\java\lib\nodeJavaBridge.js:316:2)

  • At this point, I tried installing and running electron-rebuild. When I re-ran the sample, I then got this error:
    App threw an error during load Error: Cannot find module '../build/jvm_dll_path.json' at Module._resolveFilename (module.js:470:15) at Function.Module._resolveFilename (C:\devel\electron-quick-start\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at C:\devel\electron-quick-start\node_modules\java\lib\nodeJavaBridge.js:3:21 at Object.<anonymous> (C:\devel\electron-quick-start\node_modules\java\lib\nodeJavaBridge.js:316:2) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32)

  • So, I thought maybe at this point, I need to rebuild the Java, so I did the following:
    cd node_modules\java node-gyp rebuild npm run postinstall cd ..\..
    Unfortunately, when I ran the sample, I simply got the first error message again.

Any ideas out there? I feel like I’m really close, but can’t quite get the build steps correct.



Having same issue… Described my issue in this link.

Tried the solution as provided. But problem still persist.


I downloaded the quick start. Unzipped. CD to quick start and this is what I did…
npm init
npm start
npm i electron-build --savedev
npm install java
npm run rebuild-modules
node node_modules\java\postinstall.js

My package.json looks like this. Do I need to add something ???

“scripts”: {
“start”: “electron .”,
“rebuild-modules”: “electron-rebuild”
“repository”: “”,
“keywords”: [
“author”: “GitHub”,
“license”: “CC0-1.0”,
“devDependencies”: {
“electron”: “^1.4.1”,
“electron-rebuild”: “^1.5.7”


npm init
npm start

please read as
npm install
npm start