Skip to content
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

Add Java process lookup for 'java.home' in find_jvm_dll_file() #89

Merged

Conversation

devinrsmith
Copy link
Member

This adds an optional check when the java-utilities package is installed.

When java-utilities is not installed, it behaves as it does today:

Python 3.10.7 (main, Sep  7 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)] on linux                                                                                    
Type "help", "copyright", "credits" or "license" for more information.                                                                                                           
>>> import jpyutil                                                                                                                                                               
>>> jpyutil.init_jvm()                                                                                                                                                           
jpyutil - WARNING: Failed to preload JVM shared library. No shared library found.                                                                                                
Traceback (most recent call last):                                                                                                                                               
  File "<stdin>", line 1, in <module>                                                                                                                                            
  File "/home/devin/dev/jpy/jpyutil.py", line 455, in init_jvm                                                                                                                   
    import jpy                                                                                                                                                                   
ImportError: libjvm.so: cannot open shared object file: No such file or directory                                                                                                
>>>

When it is installed, it uses the java.home found from the java found on the path:

Python 3.10.7 (main, Sep  7 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)] on linux                                                                                    
Type "help", "copyright", "credits" or "license" for more information.                                                                                                           
>>> import jpyutil                                                                                                                                                               
>>> jpyutil.init_jvm()                                                                                                                                                           
(<CDLL '/usr/lib/jvm/java-17-openjdk-17.0.4.1.1-1.fc36.x86_64/lib/server/libjvm.so', handle 55a7d4beb1d0 at 0x7f14d714fbb0>, ['-Djpy.jpyLib=/tmp/jpy/lib64/python3.10/site-packag
es/jpy.cpython-310-x86_64-linux-gnu.so', '-Djpy.jdlLib=/tmp/jpy/lib64/python3.10/site-packages/jdl.cpython-310-x86_64-linux-gnu.so', '-Djpy.pythonLib=/usr/lib64/libpython3.10.so
', '-Djpy.pythonPrefix=/tmp/jpy', '-Djpy.pythonExecutable=/tmp/jpy/bin/python'])                                                                                                 
>>>

Fixes #82

@devinrsmith devinrsmith merged commit b16180c into jpy-consortium:master Sep 26, 2022
@devinrsmith devinrsmith deleted the java-process-java-home branch September 26, 2022 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve jpyutil to preload based via java subprocess
2 participants