在Ubuntu中设置JAVA_HOME环境变量 [英] Setting the JAVA_HOME environment variable in Ubuntu

查看:408
本文介绍了在Ubuntu中设置JAVA_HOME环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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

但是我有以下错误:


找不到合适的java安装。如果你已经安装了java
请在继续之前设置你的JAVA_HOME环境变量。否则,需要将
合适的java安装添加到本地系统。

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.

安装Java

在OSX上从命令行运行 javac 。这将启动安装。对于
Linux系统,请参阅相关软件包管理器上的文档。

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.

但我很确定我有Java,那么请问我如何设置我的JAVA_HOME环境变量?

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

推荐答案

首先,您需要决定使用哪个安装的Java版本?不用担心,你可以随便挑选 -

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

update-java-alternatives -l

一个简单的解决方案是将其添加到$ HOME / .bashrc,

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

export JAVA_HOME=$(update-java-alternatives -l | head -n 1 | cut -f3 -d' ')

这会选择第一个已安装的JDK并将其作为JAVA_HOME(第三个字段) - 在我的系统上

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

这篇关于在Ubuntu中设置JAVA_HOME环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆