set JAVA_HOME in RHEL/CentOS
3.3. Install OpenJDK on Red Hat Enterprise Linux
OpenJDK is one of many Java Development Kits (JDKs) supported in Red Hat Enterprise Linux for use with JBoss enterprise products. This task shows you how to install OpenJDK in Red Hat Enterprise Linux, and how to configure your system to use it as the default JDK.
Note
You must meet the following conditions before continuing with this task:
- You must be running Red Hat Enterprise Linux 6. OpenJDK is not available or supported for Red Hat Enterprise Linux 5 at this time.
- The server running Red Hat Enterprise Linux 6 must be registered with RHN and subscribed to the base channel. Refer to the Package Management section of the Red Hat Enterprise Linux 6 Deployment Guide on https://access.redhat.com/knowledge/docs/ for more information about managing subscriptions and entitlements on Red Hat Enterprise Linux systems.
Install the OpenJDK RPM.
There are two different ways to install an RPM, depending on whether you have used a command-line interface (CLI) or a Graphical User Interface (GUI).From the CLI
After logging in with administrator access, run one of the following two commands:- OpenJDK 6
-
yum install java-1.6.0-openjdk-devel - OpenJDK 7
-
yum install java-1.7.0-openjdk-devel
From a GUI
- In Gnome, select Administration from the System menu, and click Add / Remove Software.
- Search for
openjdkand choose thejava-1.6.0-openjdk-develoption for OpenJDK 6 or thejava-1.7.0-openjdk-develoption for OpenJDK 7. - Click Apply to install the selected packages and dependencies.
- When prompted, enter the administrator password to install the packages.
Optional: Set the
JAVA_HOMEenvironment variable.Some applications such as Apache Maven and Apache Ant require you to set theJAVA_HOMEenvironment variable. If you need to do this, follow these steps.- Determine the correct value for
JAVA_HOME. Red Hat Enterprise Linux installs OpenJDK 1.6 into either/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/or/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/, depending on whether your system is a 32-bit or 64-bit architecture. TheJAVA_HOMEshould point to the directory containing abin/javaexecutable. - As the user who will use OpenJDK, open the shell configuration file. For the Bash shell, this file is
/home/.username/.bashrc - At the bottom of the file, type the following line, replacing the hypothetical path with the actual path to use on your own system:
export JAVA_HOME="/path/to/java/home" - Save the file, and log out of and back into your session.
Switch between different OpenJDK versions using the
alternativesutility.Red Hat Enterprise Linux includes a utility calledalternatives, which lets you change the default version for applications which allow multiple versions to be installed. OpenJDK is one such application.To use thealternativesutility, perform the following steps. Note that setting the environment variables overrides the behavior of thealternativescommand. For instance, if you use a script which manually sets$JAVA_HOMEand$JAVAvariables to a different JDK from the one specified by thealternativescommand, the environment variables will override the command.- Log in as the
rootuser, or prefix the commands below with thesudocommand. - The
alternativescommand is not installed by default, but may already be installed on your system. If not, install thealternativespackage by running the following command:yum install alternatives
- Issue the following command:
/usr/sbin/alternatives --config java
- Follow the prompts that follow to set the default version of OpenJDK.
OpenJDK is installed on your server and available for your use. If necessarily, the JAVA_HOMEenvironment variable has been specified as well. If necessary, the default OpenJDK for your system has been set using the alternatives utility.
Set JAVA_HOME
Ensure all users have their JAVA_HOME environment variable set to the correct value:
echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64" > /etc/profile.d/java_home.sh
set JAVA_HOME in RHEL/CentOS的更多相关文章
- (转)RHEL/CentOS 6.x使用EPEL6与remi的yum源安装MySQL 5.5.x
PS:如果既想获得 RHEL 的高质量.高性能.高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 Fedora Project 推出的 EPEL(Extra Packages for En ...
- RHEL/CentOS 7最小化安装后需做的30件事情
导读 CentOS是一个工业标准的Linux发行版,是红帽企业版 Linux 的衍生版本.你安装完后马上就可以使用,但是为了更好地使用你的系统,你需要进行一些升级.安装新的软件包.配置特定服务和应用程 ...
- RHEL/CentOS/Fedora各种源(EPEL、Remi、RPMForge、RPMFusion)配置
最新文章:Virson’s Blog CentOS默认自带CentOS-Base.repo源,但官方源中去除了很多有版权争议的软件,而且安装的软件也不是最新的稳定版.Fedora自带的源中也找不到很多 ...
- How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7
How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7 The problem Google developers s ...
- Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x
This howto guide shows you’ll how to enable EPEL repository under RHEL/CentOS 6/5 to install additio ...
- Google Chrome 55 Released – Install on RHEL/CentOS 7/6 and Fedora 25-20
Google Chrome is a freeware web browser developed by Google Inc. Google Chrome team proudly announce ...
- Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务
RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...
- RHEL/CentOS 6.x 系统服务详解
PS:RHEL/CentOS 6.x的系统服务比5.x系列的要多了很多新面孔,估计很多童鞋不甚理解,网上这方面资料也很少.理解这个对运维人员是必要的,因为开启不必要的服务越 多,系统就相对越不安全.不 ...
- Install TightVNC Server in RHEL/CentOS and Fedora to Access Remote Desktops
Virtual Networking Computing (VNC) is a Kind of remote sharing system that makes it possible to take ...
随机推荐
- Java 导出EXCEL
1.Apache POI简介 Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程式对Microsoft Office格式档案读和写的功能. .NET的开发人员则 ...
- innerHTML,innertext ,textcontent,write()
innerhtml属于对象的一个属性,一般用于向已经存在的标签中写入内容,或者读取标签的内容. innertext属于对象的一个属性,一般只能用于写入内容,或者读取内容,不能读取dom 中的标签,且只 ...
- C#实现右下角弹出窗口效果
/// <summary> /// 窗体动画函数 注意:要引用System.Runtime.InteropServices; /// </summary> /// <pa ...
- UIkit框架之UIPickerView
1.继承链:UIview:UIResponder:NSObject 2.获取uipicker view的属性 (1)@property(nonatomic, readonly) NSIntegernu ...
- HDU1005(矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 #include<cstdio> using namespace std; int ...
- error CS0103: 当前上下文中不存在名称“ViewBag”
error CS0103: 当前上下文中不存在名称“ViewBag” View文件夹下缺少web.config文件
- 详解Objective-C runtime
感谢翻译小组成员wingpan热心翻译.本篇文章是我们每周推荐优秀国外的技术类文章的其中一篇.如果您有不错的原创或译文,欢迎提交给我们,更欢迎其他朋友加入我们的翻译小组(联系qq:2408167315 ...
- @SuppressWarnings有什么用处?
J2SE 提供的最后一个批注是 @SuppressWarnings.该批注的作用是给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默. @SuppressWarnings 批注允许您选择 ...
- springMVC返回json
<mvc:annotation-driven> <mvc:message-converters register-defaults="true"> < ...
- codeforces 381 D Alyona and a tree(倍增)(前缀数组)
Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...