Search code examples
javaenvironment-variablessnap-python

How to set JDK_HOME


I try to work with the snappy module in python using conda as a virtuelenv. I have in Linux Mint 18 Sarah.

I have the module snappy, but if i try to test it with the following code: from snappy import ProductIO I got the following response:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mara/.snap/snap-python/snappy/__init__.py", line 61, in <module>
    import jpyutil
ImportError: No module named 'jpyutil'

Thus, I tried to get jdk with pip install -i https://pypi.anaconda.org/pypi/simple jpy . And i got: Error: Environment variable "JDK_HOME" must be set to a JDK (>= v1.6) installation directory

Thus, I installed jdk1.8.0_111. I used this instruction: https://community.linuxmint.com/tutorial/view/1372. But I don't know how to set the JDK_HOME variable in a correct way. I tried it using an instruction for JAVA_HOME (https://askubuntu.com/questions/175514/how-to-set-java-home-for-java) and write JDK_HOME="/opt/java/jdk1.8.0_111" in the environment file but it doesn't work. I got the same Error like before changing the environment file.

Hope somebody can help me.


Solution

  • Create a symbolic link:

    ln -s /opt/java/jdk1.8.0_111 /opt/java/latest
    

    Directory listing for /opt/java:

    .
    jdk1.8.0_111/
    latest/ -> /opt/java/jdk1.8.0_111
    

    Set exports

    export JDK_HOME=/opt/java/latest
    export JAVA_HOME=${JDK_HOME}
    export PATH=$PATH:${JAVA_HOME}/bin
    

    Now, when you install a new version of the Java JDK, simply alter your latest symbolic link.