Error "Unknown JNI version: 11". Support for Java >= 11
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
- Official documentation
-
./node_modules/java-bridge/dist/definitions.d.ts
, "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?
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.