If you see an error such as "Call to 'node findJavaHome.js' returned exit status 1"
Try running node ./scripts/findJavaHome.js in the node-java directory to see the full failure message.
If you are having problems finding 'jni.h'. Make sure you have the JDK installed not just the JRE. If you are using
OpenJDK you want the openjdk-7-jdk package, not openjdk-7-jre. Mavericks users see Issue #86 if you run into this.
Installation Ubuntu
sudo apt install make g++
If u've error (on global installation): EACCES user nobody does not have permission to access the dev dir /root/.cache/node-gyp/10.16.0, then just run: npm i -g java --unsafe-perm
Installation OSX
If you run into strange runtime issues, it could be because the Oracle JDK does not advertise itself as available for JNI. See Issue 90 for more details and manual workarounds. If this does occur for you, please update the issue.
when using the windows SDK 7.1 command prompt (64 bits) be sure to setenv.cmd /Release /x86
If you get ENOENT errors looking for <nodepath>\node_modules\node-gyp\.., ensure you have node-gyp installed as a global nodule:
npm install -g node-gyp
If you get D9025 warnings and C1083 errors when looking for .sln or .h files, be sure you've got the node-gyp's dependencies, as explained here.
Alternatively, Windows users can easily install all required tools by running the following command in PowerShell as administrator. For more information see windows-build-tools project page:
JavaScript only supports 32-bit integers. Because of this java longs must be treated specially.
When getting a long result the value may be truncated. If you need the original value there is
a property off of the result called "longValue" which contains the un-truncated value as a string.
If you are calling a method that takes a long you must create it using java.newInstance.
const javaLong = java.newInstanceSync("java.lang.Long", 5);console.log('Possibly truncated long value: ' + javaLong);console.log('Original long value (as a string): ' + javaLong.longValue);java.callStaticMethodSync("Test", "staticMethodThatTakesALong", javaLong);
Exceptions
Exceptions from calling methods either caught using JavaScript try/catch block or passed
to a callback as the first parameter may have a property named "cause" which has a reference
to the Java Exception object which caused the error.
With v0.5.1 a new API is available to make it easier for a complex application to have full control over JVM creation. In particular, it is now easier to compose an application from several modules, each of which must add to the Java classpath and possibly do other operations just before or just after the JVM has been created. See the methods ensureJvm and registerClient. See also several of the tests in the testAsyncOptions directory.
Release Notes
v0.5.0
Support for varargs. This change is not 100% backwards compatible, but the fix is generally easy and results in more natural code.
v0.2.0
java.lang.Long and long primitives are handled better. See
(Issue #37) and
(Issue #40).