Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 981
Marek Avatar asked Dec 07 '16 13:12

Marek


People also ask

How do I change my java home path?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.

What should be JAVA_HOME?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.

Do we need to set path for JRE?

The path is required to be set for using tools such as javac, java, etc. If you are saving the Java source file inside the JDK/bin directory, the path is not required to be set because all the tools will be available in the current directory.


Video Answer


1 Answers

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.

like image 195
Mr. Polywhirl Avatar answered Sep 20 '22 13:09

Mr. Polywhirl