Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Unknown JNI version: 11". Support for Java >= 11 #107

Closed
alberthastings opened this issue Aug 14, 2024 · 1 comment · Fixed by #108
Closed

Error "Unknown JNI version: 11". Support for Java >= 11 #107

alberthastings opened this issue Aug 14, 2024 · 1 comment · Fixed by #108

Comments

@alberthastings
Copy link

My test

Used versions:

  • O.S.: Ubuntu 22.04.4 LTS
  • Node: v20.12.2
  • java-bridge: 2.6.0

Node script:

import javaBridge from 'java-bridge';
javaBridge.ensureJvm({
   classpath: [],
   ignoreUnreadableClassPathEntries: false,
   isPackagedElectron: false,   
   libPath: '/opt/jdk-11.0.21+9/lib/server/libjvm.so',   
   opts: [],   
   version: '11'
});
const System = javaBridge.importClass('java.lang.System');
System.out.println('Hello world!');

Execution result:

Error: Unknown JNI version: 11
   at Object.c (.../node_modules/java-bridge/dist/index.prod.min.js:1:9102)
   at .../src/main.js:3:12
   at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
   at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
   at async loadESM (node:internal/process/esm_loader:28:7)
   at async handleMainPromise (node:internal/modules/run_main:113:12) {code: 'GenericFailure'}

Note: Tested with

libPath: '/opt/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so',   
version: javaBridge.JavaVersion.VER_8

gives sucessfull result.

My request

According to

, "java-bridge" only supports these Java versions: 1.1, 1.2, 1.4, 1.6, 1.8, 9, and 10.

Could you implement support for Java >= 11?

@MarkusJx
Copy link
Owner

As far as I know, this parameter only sets the JNI version to be used, not the JVM version being used. The JVM version used depends on the JRE you are running this package with.

For older JNI versions, 10 is actually the highest one available, enabling support for JNI 10 or higher. Starting from Java 19, they've added three new JNI versions, those being 19, 20 and 21, so I may add those in the future, although I'm not really seeing a benefit to doing this as it won't affect the JVM version being used. I'll definitely have to update the documentation regarding this option, since the current documentation isn't quite accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants