6

I am following this How to set JAVA_HOME for Java? in order to set the environment variable JAVA_HOME to the correct version. I have different versions of java in my /usr/lib/jvm/folder as illustrated in the following picture.

enter image description here

I added JAVA_HOME="/usr/lib/jvm/java-8-oracle"to the environment file.

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export JAVA_HOME

however if I run google-refine I have the following error:

./refine: 98: [: /tmp/refine.S4a2EGD: unexpected operator
Google Refine requires Java version 6 or later. If you have multiple versions of Java installed, please set the environment variable JAVA_HOME to the correct version.
8
  • It's so hard to read that text in the second picture, can you please edit and copy paste those three lines in your question? – usmanayubsh Sep 13 '17 at 13:14
  • 2
    @usmanayubsh I replaced the figure with the text of the file. – emax Sep 13 '17 at 13:16
  • 1
    Please execute these commands to check: java -version and printenv | grep JAVA_HOME. If $JAVA_HOME gives nothing, you must add new PATH definition at end of these files: ~/.bashrc and ~/.profile – Redbob Sep 13 '17 at 13:36
  • @Redbob If I type java -version I have java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) while after printenv | grep JAVA_HOME I have JAVA_HOME=/usr/lib/jvm/java-8-oracle – emax Sep 13 '17 at 13:43
  • 1
    Please execute this sudo update-alternatives --display java. Maybe Google-refine is not understanding your Default Java, or it will work better with JDK (you are running JRE). If the result of this command above is not as expected, visit this page to adjust your java environment – Redbob Sep 13 '17 at 14:00
4

If you installed java from ppa it sets JAVA_HOME locally in:

/etc/profile.d/jdk.sh

which is added to env on user login. You can edit this file or if you use etckeeper better way is to checkout this file to any version you require.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.