Search code examples
javapython-2.7pyjnius

How to select java version for pyjnius


I have Java 1.6.0_17 installed in /usr/local/bin. My Java program is compiled with 1.7.0_11.

pyjnius fails in a call X = autoclass('HelloWorld')

When HelloWorld.java is compiled with 1.6, everything works.

I cannot get pyjnius working with 1.7.

I've tried setting JAVA_HOME before importing jnius:

import os
os.environ['JAVA_HOME'] = '/usr/local/pkgs/jdk-1.7.0.11'
from jnius import autoclass
XX = autoclass('HelloWorld')

I've also set JAVA_HOME in .bash_profile and added /usr/local/pkgs/jdk-1.7.0.11/bin the first in my PATH.


Solution

  • pyjnius needs to be reinstalled in order to configure it with the new java environment. That can be done by running the following in the downloaded or cloned pyjnius GiHub project folder:

    sudo python setup.py install