-
Notifications
You must be signed in to change notification settings - Fork 282
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
OS X JDK 1.7 failing to load #90
Comments
At which point in your code the error comes up? Tested on my system (OS X 10.9 with 1.7.0_45) right now and it works. |
My code was simply: var java = require("java");
var list = java.newInstanceSync("java.util.ArrayList"); The error occurs on line 2 (determined by inserting a console.log) there is no stack trace. |
Seems like the java environment isn't set up correctly on your system. The only place I found this file on mine is: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libserver.dylib, which is the pre-installed java version that came with previous versions of OS X. What are your Java environment variables? (JAVA_HOME, ...) |
OS X 10.9 (Mavericks) does not come with Java installed. The Apple version of Java 1.6 is available as an update but not Java 1.7, which must be downloaded from Oracle. I do not have any environmental variables set regarding Java, there is no JAVA_HOME or Java directories in the PATH as Oracle's installer did not set them. I think the problem may be that node-java assumes that Apple's version of Java is installed, which is not necessarily true. |
No node-java works with both, pre-installed and others. If you upgraded from previous versions of osx you can indeed have the pre-installed jdk under /System/Library. Try setting JAVA_HOME |
I have a fresh installation of Mavericks, not an upgrade. node-java needs to work out of the box with Oracle Java 7... |
I've done some investigating - as you said the JDK under
The user-accesible (or just Oracle?) JDKs are under
The Oracle JDK 7's
as you can see, there is no |
I think find-java-home would help out here. |
@jahewson Now that 0.3.0 is published, can you try installing again with 0.3.0? |
I'm still seeing this with 0.3.2, OS X 10.9.2.
I'm also using |
@joeferner should we add |
That would probably make sense. Anyone have OSX to try it on? |
I'm happy to test anything if you can give me a patch or tell me how to modify my local install :) |
@TheSpyder can you try adding |
well that was interesting :) Do I need to run a particular command to get more detail? |
hmmmm.... That is interesting. You're getting a different error now though which is promising! Can you do this and paste the output of
cc @joeferner. I'm guessing that error is related to |
I don't want to spam anyone's inbox, so I put it on pastebin :) |
@TheSpyder @joeferner looks like that error is happening for other Mavericks users without @TheSpyder what version of java and node are you using? |
ahh, well I have upgraded node recently. I try to keep it up to date. Node v0.10.28 I have, however, installed node via homebrew if that makes any difference. |
@TheSpyder you might try with other versions of |
@TheSpyder you may attempt the proposed debugging instructions in that bountysource link I posted. It may be related to a function within |
I'm not familiar with gdb, so I'd need help to get a backtrace. The error is definitely coming from newInstanceSync, even this is enough to do it:
And just to be sure, I tried passing an empty and incorrect strings to newInstanceSync - still failed. It doesn't even manage to check if the class exists. |
@TheSpyder I'm no c++ expert. You may attempt adding print statements in src/Java.cpp#newInstanceSync and re-build. That could let you know where the failure is at. |
I was trying older versions of node, no dice. Adding printf to help debug the method calls revealed this nugget in Java::createJVM:
10 prints, then crash without 11. I'm no C guru either, but doesn't that read as classPath has been declared but not defined before use? :) |
hmm. git history shows that's been there since 2012, so clearly I'm off base somehow. I just installed 0.3.3 plain and I'm getting the same error, so it wasn't anything you did :) |
ooh, and I'm getting it with 0.3.2 as well. When I remove JDK 1.7 and 1.8 and type It looks like Java 1.6 is officially dead on OS X. They must've snuck that in with 10.9.3 (I only just realised I was still on 10.9.2 when I first posted here). |
@TheSpyder @TheSpyder @jahewson are you using macports? Can you verify that you're compiling with @joeferner this (http://stackoverflow.com/questions/21413852/simple-protocol-buffers-program-works-when-compiled-with-g-but-not-clang) seems to be very relevant. |
And here we have this: https://trac.macports.org/wiki/UsingTheRightCompiler.
@TheSpyder @jahewson I'm guessing |
@TheSpyder looks like I may have been wrong about @joeferner From http://clang.llvm.org/compatibility.html, "Clang does not zero initialize local block variables, and programs which rely on such behavior will most likely break when built with Clang." |
@TheSpyder is it safe to close the issue then? |
Yes. I don't believe you can fix this. It's worth adding a note (and possibly my suggested workarounds) to the readme, though. |
Thanks @TheSpyder! I think for now we can close it. Can you submit a PR with the README addition? |
Thanks, @TheSpyder! That was super helpful. Installation steps for the next person to stumble upon this issue: $ brew install caskroom/cask/brew-cask
$ brew tap caskroom/homebrew-versions
$ brew cask install java7 |
This is copying the behaviour found in the [java](https://github.com/caskroom/homebrew-cask/blob/master/Casks/java.rb#L21) cask and resolves an issue with node-java (as described [here](joeferner/node-java#90 (comment))).
This is copying the behaviour found in the [java](https://github.com/caskroom/homebrew-cask/blob/master/Casks/java.rb#L21) cask and resolves an issue with node-java (as described [here](joeferner/node-java#90 (comment))).
@TheSpyder any idea why JDK doesn't advertise itself as supporting JNI? |
@junqdu no idea. I don't think Oracle cares about Java on OS X much anymore. |
Adding JNI to the list of JVMCapabilities worked perfectly for me. |
@TheSpyder Thanks for your solution, adding JNI also works for me! Thanks !! |
@TheSpyder @jsdevel There is another, better way to avoid this horrible issue: load |
nice @ctrueden ! can you open a pr? |
Interesting. That ImageJ dev seems to like to rant about Apple. I'm amused that there were three working methods to fix the same issue; perhaps the config patch only worked by accident. Your second link (xamarin) points to this OpenJDK bug, which was fixed in Java 9: So while this change is probably harmless on new releases, it seems only necessary on now-unsupported versions of Java (Java 8 fell out of Oracle support in Jan 2019).
Note that manual patching wasn't required for homebrew users, the cask did that in a post install script. Although that was been removed after someone discovered it didn't makes sense in Java 11. |
I'm using OS X 10.9 with Sun's JDK 1.7 and always get the following error:
Indeed, the folder
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bundle
does not exist on my system.I'm using Sun's JDK 1.7, and do not have Apple's installed. The output of
java -version
is:The text was updated successfully, but these errors were encountered: