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.
emax
  • 171
  • 1
  • 1
  • 6
  • 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
  • @Redbob I have java - auto mode link best version is /usr/lib/jvm/java-8-oracle/jre/bin/java link currently points to /usr/lib/jvm/java-8-oracle/jre/bin/java link java is /usr/bin/java slave java.1.gz is /usr/share/man/man1/java.1.gz /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081 slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz /usr/lib/jvm/java-8-oracle/jre/bin/java - priority 1081 slave java.1.gz: /usr/lib/jvm/java-8-oracle/man/man1/java.1.gz – emax Sep 13 '17 at 14:10
  • Possibly Oracle Java has no priority to Google-refine, even if JAVA_HOME is settled. Follow these instructions to establish Oracle Java as priority to your system. In my case, I'd rather to uninstall all other and left only Oracle Java. – Redbob Sep 13 '17 at 14:28
  • Side comment: That line export JAVA_HOME is redundant. /etc/environment is not a script file. – Gunnar Hjalmarsson Sep 13 '17 at 16:18

1 Answers1

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.

Amorphous
  • 135