OS X JDK 1.7 failing to load
I'm using OS X 10.9 with Sun's JDK 1.7 and always get the following error:
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Segmentation fault: 11
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:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
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 /System/Library/Java is present on Mavericks, but I think it's intended for system use (or is this just where Apple keeps its JDK?):
ls /System/Library/Java/JavaVirtualMachines
1.6.0.jdk
The user-accesible (or just Oracle?) JDKs are under /Library/Java and I only have Oracle's JDK 1.7:
~$ ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_45.jdk
The Oracle JDK 7's Home directory contents is:
~$ ls /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/
COPYRIGHT include
LICENSE jre
README.html lib
THIRDPARTYLICENSEREADME-JAVAFX.txt man
THIRDPARTYLICENSEREADME.txt release
bin src.zip
db
as you can see, there is no bundle directory, which relates to the original error message.
I think find-java-home would help out here.
@jahewson 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.~~
@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.
shinji:corpus spyder$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
shinji:corpus spyder$ node corpus.js
<startup output>
No Java runtime present, requesting install.
I'm also using java.newInstanceSync.
@joeferner should we add libserver.dylib to postInstall.js?
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 git+https://github.com/jsdevel/node-java.git#a4c47f938903957f578c7f228f4aad34b6cfdb32 in your package.json for java?
node(94131,0x7fff7d3e0310) malloc: *** error for object 0x103f7e7c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
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 ~/contents-of-java-home.txt?
cd node_modules/javacd "node findJavaHome.js"find . > ~/contents-of-java-home.txt
cc @joeferner. I'm guessing that error is related to node-java trying to free a pointer that hasn't been created yet?
I don't want to spam anyone's inbox, so I put it on pastebin :)
http://pastebin.com/mAxiwt05
@TheSpyder @joeferner looks like that error is happening for other Mavericks users without node-java https://www.bountysource.com/issues/1126096-tree-diffindex-pointer-being-freed-was-not-allocated.
@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 Java latest (tried both 1.7.0_55 and 1.8.0_05 by changing JAVA_HOME)
I have, however, installed node via homebrew if that makes any difference.
@TheSpyder you might try with other versions of node if you can.