Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the JAVA_HOME environment variable in Ubuntu

I'm pretty new on ubuntu, at some point in the terminal I'm running:

mortar local:illustrate pigscripts/retail-recsys.pig purchase_input -f params/retail.params

but I have this following error:

A suitable java installation could not be found. If you already have java installed
please set your JAVA_HOME environment variable before continuing. Otherwise, a suitable java installation will need to be added to your local system.

Installing Java

On OSX run javac from the command line. This will intiate the installation. For Linux systems please consult the documentation on your relevant package manager.

But I'm pretty sure I have Java, so please how can I set my JAVA_HOME environment variable?

like image 709
user2461031 Avatar asked Apr 17 '14 04:04

user2461031


People also ask

Where is JAVA_HOME set in Ubuntu?

You can set your JAVA_HOME in /etc/profile as Petronilla Escarabajo suggests. But the preferred location for JAVA_HOME or any system variable is /etc/environment .

How do I set JAVA_HOME environment variable?

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 is JAVA_HOME Ubuntu?

The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed. This variable should be configured on all OS's that have a Java installation, including Windows, Ubuntu, Linux, Mac and Android.


1 Answers

First, you need to decide which installed version of Java to use? No fear, you can pick any you have -

update-java-alternatives -l

One "easy" solution is to add this to "$HOME/.bashrc",

export JAVA_HOME=$(update-java-alternatives -l | head -n 1 | awk -F ' ' '{print $NF}')

This picks the first installed JDK and takes it's JAVA_HOME (the third field) - on my system that's

/usr/lib/jvm/java-1.7.0-openjdk-amd64
like image 198
Elliott Frisch Avatar answered Oct 25 '22 10:10

Elliott Frisch