Skip to content

macos electron use node-java-bridge, macos electron use node-java-bridge ,error: Uncaught Exception: Error: java.lang.ClassNotFoundException: io.github.markusjx.bridge.NativeLibrary #111

Open

Description

@code565

I used 'node java' in 'electron' and after packaging DMG, the button triggered the connection to 'jar', but an error occurred
Image

err:
chunk-libs.befb8490.js:67 Error: Error invoking remote method 'handle-jar': Error: java.lang.ClassNotFoundException: io.github.markusjx.bridge.NativeLibrary
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at crates/java-rs/src/j…_env_wrapper.rs:765
at crates/java-rs/src/j…_env_wrapper.rs:323
at EventEmitter.i.invoke (node:electron/js2c/renderer_init:57:526)
at async i.handleJar (chunk-2e62c82d.7c30320e.js:1:68842)
chunk-dc348ffc.858acd80.js:1

this is mycode
`

Image

`

Activity

  1. MarkusJx commented on Mar 21, 2025

    @MarkusJx
    Owner

    You may want to try setting isPackagedElectron to true when calling ensureJVM, before calling any other methods of this package.

  2. fmannhardt commented on Sep 29, 2025

    @fmannhardt

    Hi. I am getting the same error when trying out java-bridge 2.8.0 in an Electron application on a Windows x64 platform. I have, as advised the configuration:

        'node_modules/java-bridge/**',
        'node_modules/java-bridge-*/**
    

    for asarUnpack and also used isPackagedElectron set to true. It seems to load the JVM and also finds the native module, but fails to include JavaBridge.jar. When investigating, I noted that in this PR:
    001b5aa
    the parameter isPackagedElectron was removed from getJavaLibPath but it is still used in the other calls in nativeLib.ts but when using 'node_modules/java-bridge/**' in asarUnpack the JAR file will be unpacked as well.

    So, shouldn't the regex workaround for asar also be used for the JAR?

  3. fmannhardt commented on Sep 29, 2025

    @fmannhardt

    I just downgraded to v2.4.0 (before the changes mentioned above) and it works fine in Electron. So, I assume the change in 001b5aa caused the issue.

  4. MarkusJx commented on Feb 21, 2026

    @MarkusJx
    Owner

    Could be fixed by #118

  5. MarkusJx commented on Feb 22, 2026

    @MarkusJx
    Owner

    Should be fixed in v2.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions