node-java-bridge
node-java-bridge copied to clipboard
macos electron use node-java-bridge, macos electron use node-java-bridge ,error: Uncaught Exception: Error: java.lang.ClassNotFoundException: io.github.markusjx.bridge.NativeLibrary
I used 'node java' in 'electron' and after packaging DMG, the button triggered the connection to 'jar', but an error occurred
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 `
`
You may want to try setting isPackagedElectron to true when calling ensureJVM, before calling any other methods of this package.
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:
https://github.com/MarkusJx/node-java-bridge/commit/001b5aa22bf1a1da3feb8f015858cd81b4e50cbd
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?
I just downgraded to v2.4.0 (before the changes mentioned above) and it works fine in Electron. So, I assume the change in https://github.com/MarkusJx/node-java-bridge/commit/001b5aa22bf1a1da3feb8f015858cd81b4e50cbd caused the issue.