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

Node Java doesn't work on different Platforms of OSX #413

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

WilliamRClark
Copy link

The primary issue with Node-Java on OSX is that the path to the Java SDK is embedded in the compiled code. This used to be OK in OSX, but the most recent versions of OSX no longer bundle Java. Users have to manually install it, and may have different versions in different locations.

This means after the code is built, Java is not necessarily accessible in the fixed location provided with the build. A solution (included in this pull request) is to compile with a link to the version of Java you wish to use. The link needs to be defined (currently in /Library/Application Support/ExportData/) which is probably not ideal. Could easily be modified to something like /Library/Application Support/node-java/.

@joeferner
Copy link
Owner

The readme change is fine but the path problem should be fixed in the https://www.npmjs.com/package/find-java-home project.

@WilliamRClark
Copy link
Author

Forgive me for my possible ignorance here, but I am unclear how any changes to find-java-home can address the underlying problem that nodejavabridge_bindings have a static path to the JVM on the build machine embedded in them. The path is correct on the machine which the native code is initially compiled on, but the path is embedded in the binary. If / when you move the binary to another machine, the path isn't guaranteed to even exist there. Is find-java-home what allows the Windows binaries to use the Registry to accurately identify the installed java path regardless of where it is built?

@joeferner
Copy link
Owner

@jsdevel did most of the work integrating find-java-home, so I'm not 100% sure if this is the correct solution, but I saw replacing javahome with an absolute path as a potential problem. I typically use Linux so I don't know much about OSX but is Java always found at /Library/Application Support/ExportData/javaLocation even on older OSX, etc.? Can you install Java to a different location?

@WilliamRClark
Copy link
Author

WilliamRClark commented Oct 10, 2017

OSX used to be bundled with java. This made it pretty simple to find. Oracle's acquisition of Java hasn't been very helpful.

This is a pretty good answer to where Java can be installed:
https://stackoverflow.com/questions/15826202/where-is-java-installed-on-mac-os-x

On a particular system, there is a convenience script similar to the registry:
/usr/libexec/java_home which returns the current default Java version.

/Library/Application Support/ExportData is a arbitrary location that we created for an app we were working on (ExportData). The Application Support directory is similar to AppData in Windows. javaLocation is a symbolic link which points to the location of the desired JVM you wish to use. The client, or an installer would have to create this link.

If you wish to incorporate this into your codebase, you might consider changing the link location to /Library/Application Support/NodeJava/

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 this pull request may close these issues.

2 participants