Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

java - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...