joeferner / node-java

Bridge API to connect with existing Java APIs.
MIT License
1.87k stars 280 forks source link

Distributing an electron app with node-java is not maintainable #361

Open antoinepairet opened 7 years ago

antoinepairet commented 7 years ago

Distributing an electron app with node-java is not maintainable Because the JVM path is bound to a specific version of JAVA.

Is there a way to have LC_RPATH resolved at runtime?

Using otool -l nodejavabridge_bindings.node (full output: otool_-l.txt) I see in the output that the path to the JVM is harcoded to a specific version:

Load command 11
          cmd LC_RPATH
      cmdsize 96
         path /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/server (offset 12)

Using otool -L:

        @rpath/libjvm.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 915.0.0)

Workarounds exists:

gpinkham commented 5 years ago

@antoinepairet "create a symbolic link pointing to the JVM running on the machine" so you mean create a link on the machine you build with like '/usr/local/java' points to '/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk' and then you just need to have the user create the link after installing your electron app? and the bindings are ok so long as the user's jdk supports that compatibility version?