Why does Pyjnius require JAVA_HOME to be set?

350 Views Asked by At

Recently, we have upgraded python version from Python 3.6 to Python 3.8. And we have noticed that Pyjnius now requires JAVA_HOME to be set.

I am wondering why it is the case though. If all what Pyjnius needs is to run java code in java virtual machine then an installation of JRE should work.

If JAVA_HOME needs to be set, we need to install JDK on all client's machines which doesn't sound like the way to go forward. We have decided to "hack" JAVA_HOME env var to make it point to JRE folder which has seemed to work.

Thank you in advance!

EDIT: I posted this question too early without proper investigation myself. Sorry and please feel free to close it.

I believe JAVA_HOME is supposed to point to a JDK installation, so by checking JAVA_HOME, jnius is suggesting JDK should be installed. This is where my confusion comes from.

Now, if I check "jnius/env.py" code, it actually checks the following: -

# prefer Env variables
JAVA_HOME = getenv('JAVA_HOME')
if not is_set(JAVA_HOME):
    JAVA_HOME = getenv('JDK_HOME')
if not is_set(JAVA_HOME):
    JAVA_HOME = getenv('JRE_HOME')
#TODO encodings

So if there is only a JRE installation available on a client's machine, it should work too. I guess on our client's machines, even with JRE installation available, the JRE_HOME env var isn't set properly, hence the issue.

0

There are 0 best solutions below