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 Java VM problems #48

Open
mpapierski opened this Issue May 3, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@mpapierski

mpapierski commented May 3, 2015

I am trying to call Java method from a compiled Java class using Python code. I dont want to run "java" executable just to run my code this I find this library really promising. Im no expert on Java but my OS X dev machine has troubles finding libjvm.dylib.

My $JAVA_HOME is:

export JAVA_HOME=$(/usr/libexec/java_home)

My libjvm.dylib is located under $JAVA_HOME/../Libraries/libjvm.dylib:

$ find $JAVA_HOME/.. -iname "libjvm.dylib" 
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Libraries/libjvm.dylib

My Java is the default one shipped with OS X 10.10:

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

But javabridge library does some nasty things to find libjvm.dylib. See https://github.com/CellProfiler/python-javabridge/blob/master/javabridge/jutil.py#L98-L113. I think this piece of code is just wrong. My point is there could be a better way to deal with libjni.dylib location.

Since I am not expert on Java, and I have basically zero knowledge about coding Java and JNI and java libs I think better approach is to try some "known paths" for different Java vendors. AFAIK there is only Oracle Java available at this moment.

After reading Java docs and materials on the internet (and examining my own system) it looks like there are two possible places where libjvm.dylib could be located:

  1. $JAVA_HOME/../Libraries
  2. $JAVA_HOME/jre/lib

My installation has only (1) option valid, and the second path is non existing.

Right now I can suggest to use (2) by default (most of sources on the internet suggests this), and maybe check if your Java on your OS X does the same as (1).

Could you replicate this issue?

Thanks!

@ljosa

This comment has been minimized.

Contributor

ljosa commented May 3, 2015

I think Java has not been shipped with Mac OS X since Mac OS X 10.6. Further, Java version 7u25 and below have been disabled by Apple on OS X. [Source]

It looks like we already try to look in the two locations that you suggest (see locate.py).

@jbcoe

This comment has been minimized.

Contributor

jbcoe commented Jun 24, 2016

Is this issue still a problem for anyone?

If the suggested paths are already checked, I would recommend closing this issue.

@LeeKamentsky

This comment has been minimized.

Owner

LeeKamentsky commented Jun 24, 2016

The user does have a point, even if it leads to an issue that I don't care to resolve in the near future. There's code in locate.py (https://github.com/LeeKamentsky/python-javabridge/blob/master/javabridge/locate.py#L42) that does a nice job using the java_home program to find the JRE and then it's done in a different way in jutil.py.

So it could be cleaner and that's an issue, but maybe there's no bug. I think I'll leave it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment