-
Notifications
You must be signed in to change notification settings - Fork 285
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 using wrong JRE on Mountain Lion 10.8.4 #61
Comments
You compiled node-java with JRE 1.6, after that you change JAVA_HOME. Don't know if the osx-java-1.7 & node-java bug is resolved already. |
Hi @joewhite86 Thanks for your response. Unfortunately, the situation is essentially the opposite of what you describe. I did set JAVA_HOME to 1.7 before "npm install java" and the module is being compiled with 1.7. One can actually be certain of this by the way, because one gets warnings about the JNI API being deprecated if one compiles with 1.6. I also set JAVA_HOME to 1.7 before running a demo script with node.js to test it, e.g. "node javademo". (Just to be clear, I've updated my initial comment because I could see how that could have been confusing.) The problem appears to be that node-java ignores JAVA_HOME at runtime and picks up the 1.6 JRE. I haven't had time to dig down into the node-java code to see if and how it picks up the path to the JRE at runtime. I did notice that if one just downloads the Master branch .zip file, there is a "./commons-lang3-node-java.jar" that contains classes that were compiled with 1.5 and a ./src-java/NodeDynamicProxyClass.class that was compiled with 1.6. I don't think these are the problem, but it seems worth noting. Thanks. |
Hi @hangarr Maybe you're right, could be at runtime or compile time. Not sure right now. The problem is the Path to the java header files is hard coded in binding.gyp. See joewhite86@cd8477f for my "quick & dirty" changes. Should give you a clue. |
Would really like to add the patch. My problem is, that the structure of the OSX built-in VM is completely different from standard installs. I did not find any possibility to add os versions to gyp. Thats what's needed for Java 1.7 installs: ['OS=="mac"',
{
"include_dirs": [
"<(javahome)/include",
"<(javahome)/include/darwin"
],
"libraries": [
"-L<(javahome)/jre/lib/server/",
"-Wl,-rpath,<(javahome)/jre/lib/server/",
"-ljvm"
]
}
] And for built-in Java 1.6: ['OS=="mac"',
{
"include_dirs": [
"/System/Library/Frameworks/JavaVM.framework/Headers"
],
"libraries": [
"-framework JavaVM"
]
}
] Putting "include_dirs" of both versions together seems to work, when JAVA_HOME is not set or set to 1.6. 2 warnings generated.
CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaObject.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/javaScope.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o
CXX(target) Release/obj.target/nodejavabridge_bindings/src/utils.o
SOLINK_MODULE(target) Release/nodejavabridge_bindings.node
ld: warning: directory not found for option '-L/System/Library/Frameworks/JavaVM.framework/Home/jre/lib/server/'
ld: library not found for -ljvm
clang: error: linker command failed with exit code 1 (use -v to see invocation) Any ideas? |
Hi @joewhite86, I do have a couple of ideas. Since of the top of my head I'm not sure which will work in the annoying Mountain Lion 10.8.4 OS X Java 6/Java 7 situation and Mountain Lion/Snow Leopard Java 6 only installation, I'd be willing to test them and get back to you with something. If I:
$ npm install <folder> will that be close enough to whatever dev/test setup you are using that whatever I find works is likely to work for your dev/test setup? (I never like to assume these things, even though they are supposed to work...) Thanks. |
Hit the wrong button... |
I cloned the repository with git and executed: # test installation
npm install
# run tests
nodeunit test |
Hi @joewhite86 - I think I have something that may work. Here's a complete "binding.gyp" that has just a couple of modifications. (The full file is added as a separate comment below)
This just grabs the root directory "System" or "Library" from JAVA_HOME. Interestingly enough, although I could do the same thing with sed:
for some reason the comparison operation in the other section of the binding.gyp file didn't work. I think it may have something to do with how gyp shells out the command and pipes.
I think this is fairly general and makes sense. If the root directory for JAVA_HOME is "Library" then the Java JRE has to have a *nix/Oracle standard layout and if it is "System" it's a Mac framework (regardless of version 1.6 or before). And if JAVA_HOME is missing, then the only thing to do is to default to the Apple framework. This seems to work for me with one caveat. I was only up to Node.js 0.10.12 when I started and that turned out to be a 32-bit installation for OS X. I had to update to Node.js 0.10.18 and everything seemed to work. Also, it turns out Apple has deprecated the Java 1.6 JNI, so "npm install" will throw warnings about this for Java 1.6. I assume this has something to do with the security updates they made in which they disabled their Java 1.6 browser plugin. The resulting install seems to work though. Does all of this make sense to you? If not, maybe you can suggest further mods? node-java is turning out to be interesting for my application. Thanks for your assistance and for node-java. Best, |
And here's the full binding-gyp that seems to work for me:
|
@hangarr Works for me on node-0.10.9 with both 1.6 and 1.7. Thanks Rick |
@joewhite86 glad to hear it worked. Thanks. |
Applied another fix for mnm.js #69 |
@joewhite86 @hangarr Can you clone my fork locally and try building that? Here's the URL: https://github.com/jsdevel/node-java.git I currently have PR for issue #94 open and I believe it will solve issues like this. |
@jsdevel - I was able to succesfully build and run unit tests of your fork On Sat, Dec 21, 2013 at 11:55 AM, Joseph Spencer
|
@joeferner I think this can be closed. |
I'm sure this has an easy solution but I haven't been able to figure it out after reviewing the node-java module code.
Environment
Installation
Tests
Running this code as "javademo.js"
appears to work, but note the JRE reported:Running code that attempts to import a custom class that was compiled with Oracle Java 1.7:
yields the expected version error:What doesn't fix this runtime JRE problem
Any tips on how to use the 1.7 JRE at runtime would be greatly appreciated. Do I perhaps need to pass some parameter to node.js and then perhaps onto the node-java module via the "javademo.js" script?
Or is this not possible and I need to compile custom Java class with a Java 1.6 target? (That works, by the way.)
Thanks.
The text was updated successfully, but these errors were encountered: