A setting that works in an Apple M1 machine

142 views
Skip to first unread message

Roberto Posenato

unread,
Dec 26, 2022, 7:54:44 AM12/26/22
to node-java
Hi,

I want to share my experience finding an updated setting for node-java in a machine with an Apple M1 processor.

I considered:
  1. OpenJDK 11, 17, and 19
  2. node 16 and 19
  3. node-java 0.12.2
After some tests, I found that the most updated (w.r.t. the versions) configuration that works in all tests is:
  1. OpenJDK 17.0.5
  2. Node 16.19.0
  3. node-java 0.12.2
Be aware that,
For installing node-java, it is necessary:
  1. to install OpenJDK 17 (I suggest to use 'brew': `brew install  openjdk@17`)
  2. to set the JAVA_HOME environment variable (
    'export JAVA_HOME=`/usr/libexec/java_home -v 17`')
  3. to modify the Java installation coping '$JAVA_HOME/include/server/jni_md.h' in '$JAVA_HOME/include/'
  4. to install 'node-gpy' package (`npm install -g node-gyp`)
  5. to install node-java (`npm install java`), ignoring the compilation warnings.
For executing  a node application that uses node-java, it is necessary:
  1. To set the environment variable 'DYLD_INSERT_LIBRARIES' to the path of JDK containing the library 'libjvm.dylib'
    For OpenJDK 17 installed through `brew`, the setting is
    `export DYLD_INSERT_LIBRARIES=${JAVA_HOME}/lib/server/libjvm.dylib`
Then, the application can be executed as usual: `node <appName>`

Roberto
Reply all
Reply to author
Forward
0 new messages