You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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?
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.
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).
A big advantage of this approach is that users do not need to manually tweak their Java installations in order to get up and running.
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.
Activity
joewhite86 commentedon Nov 21, 2013
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.
jahewson commentedon Nov 21, 2013
My code was simply:
The error occurs on line 2 (determined by inserting a console.log) there is no stack trace.
joewhite86 commentedon Nov 22, 2013
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, ...)
jahewson commentedon Nov 22, 2013
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.
joewhite86 commentedon Nov 22, 2013
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
jahewson commentedon Nov 22, 2013
I have a fresh installation of Mavericks, not an upgrade. node-java needs to work out of the box with Oracle Java 7...
jahewson commentedon Nov 22, 2013
I've done some investigating - as you said the JDK under
/System/Library/Javais present on Mavericks, but I think it's intended for system use (or is this just where Apple keeps its JDK?):The user-accesible (or just Oracle?) JDKs are under
/Library/Javaand I only have Oracle's JDK 1.7:The Oracle JDK 7's
Homedirectory contents is:as you can see, there is no
bundledirectory, which relates to the original error message.jsdevel commentedon Dec 19, 2013
I think find-java-home would help out here.
jsdevel commentedon Dec 21, 2013
@jahewson Can you clone my fork locally and try building that? Here's the URL: https://github.com/jsdevel/node-java.gitI 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?
TheSpyder commentedon May 7, 2014
I'm still seeing this with 0.3.2, OS X 10.9.2.
I'm also using
java.newInstanceSync.jsdevel commentedon May 23, 2014
@joeferner should we add
libserver.dylibtopostInstall.js?joeferner commentedon May 23, 2014
That would probably make sense. Anyone have OSX to try it on?
TheSpyder commentedon May 25, 2014
I'm happy to test anything if you can give me a patch or tell me how to modify my local install :)
jsdevel commentedon May 25, 2014
@TheSpyder can you try adding
git+https://github.com/jsdevel/node-java.git#a4c47f938903957f578c7f228f4aad34b6cfdb32in your package.json forjava?TheSpyder commentedon May 25, 2014
well that was interesting :)
Do I need to run a particular command to get more detail?
28 remaining items
jsdevel commentedon Jun 12, 2014
@TheSpyder is it safe to close the issue then?
TheSpyder commentedon Jun 12, 2014
Yes. I don't believe you can fix this. It's worth adding a note (and possibly my suggested workarounds) to the readme, though.
jsdevel commentedon Jun 12, 2014
Thanks @TheSpyder! I think for now we can close it. Can you submit a PR with the README addition?
seshness commentedon Feb 28, 2015
Thanks, @TheSpyder! That was super helpful.
It looks like the homebrew cask installation for Java 7 now applies your first suggested workaround: https://github.com/caskroom/homebrew-versions/blob/master/Casks/java7.rb#L17
Installation steps for the next person to stumble upon this issue:
Add JNI as a capability of the JVM
Add JNI as a capability of the JVM (#28607)
junqdu commentedon Mar 13, 2017
@TheSpyder any idea why JDK doesn't advertise itself as supporting JNI?
TheSpyder commentedon Mar 16, 2017
@junqdu no idea. I don't think Oracle cares about Java on OS X much anymore.
scottellis64 commentedon Oct 30, 2017
Adding JNI to the list of JVMCapabilities worked perfectly for me.
caiyufei commentedon Feb 22, 2018
@TheSpyder Thanks for your solution, adding JNI also works for me! Thanks !!
ctrueden commentedon Apr 24, 2019
@TheSpyder @jsdevel There is another, better way to avoid this horrible issue: load
libjlibefore loadinglibjvm. The ImageJ project uses this trick for its launcher successfully. And here is another example of a project using this solution. A big advantage of this approach is that users do not need to manually tweak their Java installations in order to get up and running.jsdevel commentedon Apr 24, 2019
nice @ctrueden ! can you open a pr?
TheSpyder commentedon Apr 24, 2019
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:
https://bugs.openjdk.java.net/browse/JDK-7131356
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.
Use libjli, not libjvm, on macOS