3.3. Install OpenJDK on Red Hat Enterprise Linux

Introduction

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

It is possible to install multiple JDKs on a single system.
Task Prerequisites

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.
  1. 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

      1. In Gnome, select Administration from the System menu, and click Add / Remove Software.
      2. Search for openjdk and choose the java-1.6.0-openjdk-devel option for OpenJDK 6 or the java-1.7.0-openjdk-devel option for OpenJDK 7.
      3. Click Apply to install the selected packages and dependencies.
      4. When prompted, enter the administrator password to install the packages.
  2. Optional: Set the JAVA_HOME environment variable.

    Some applications such as Apache Maven and Apache Ant require you to set the JAVA_HOMEenvironment variable. If you need to do this, follow these steps.
    1. 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. The JAVA_HOME should point to the directory containing a bin/java executable.
    2. As the user who will use OpenJDK, open the shell configuration file. For the Bash shell, this file is /home/username/.bashrc.
    3. 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"
    4. Save the file, and log out of and back into your session.
  3. Switch between different OpenJDK versions using the alternatives utility.

    Red Hat Enterprise Linux includes a utility called alternatives, which lets you change the default version for applications which allow multiple versions to be installed. OpenJDK is one such application.
    To use the alternatives utility, perform the following steps. Note that setting the environment variables overrides the behavior of the alternatives command. For instance, if you use a script which manually sets $JAVA_HOME and $JAVA variables to a different JDK from the one specified by the alternatives command, the environment variables will override the command.
    • Log in as the root user, or prefix the commands below with the sudo command.
    • The alternatives command is not installed by default, but may already be installed on your system. If not, install the alternatives package 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.
Result:

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的更多相关文章

  1. (转)RHEL/CentOS 6.x使用EPEL6与remi的yum源安装MySQL 5.5.x

    PS:如果既想获得 RHEL 的高质量.高性能.高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 Fedora Project 推出的 EPEL(Extra Packages for En ...

  2. RHEL/CentOS 7最小化安装后需做的30件事情

    导读 CentOS是一个工业标准的Linux发行版,是红帽企业版 Linux 的衍生版本.你安装完后马上就可以使用,但是为了更好地使用你的系统,你需要进行一些升级.安装新的软件包.配置特定服务和应用程 ...

  3. RHEL/CentOS/Fedora各种源(EPEL、Remi、RPMForge、RPMFusion)配置

    最新文章:Virson’s Blog CentOS默认自带CentOS-Base.repo源,但官方源中去除了很多有版权争议的软件,而且安装的软件也不是最新的稳定版.Fedora自带的源中也找不到很多 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务

    RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...

  8. RHEL/CentOS 6.x 系统服务详解

    PS:RHEL/CentOS 6.x的系统服务比5.x系列的要多了很多新面孔,估计很多童鞋不甚理解,网上这方面资料也很少.理解这个对运维人员是必要的,因为开启不必要的服务越 多,系统就相对越不安全.不 ...

  9. 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 ...

随机推荐

  1. 使用查询(SQ01、SQ02、SQ03)创建报表

    查询需求说明 通过Query(SQ01.SQ02.SQ03)实现根据销售组织查询销售订单中的各项信息,包括物料.金额.成本,以及毛利. 其中对销售组织进行权限检查(Authority Check),字 ...

  2. 用php完成数据库的增删改查

    <?php//一.连接数据库$con = mysql_connect("localhost","root","");//二.验证是否连 ...

  3. .NET 强引用和弱引用

    一:什么是弱引用 了解弱引用之前,先了解一下什么是强引用 例如 : Object obj=new Object();     就是一个强引用,内存分配一份空间给用以存储Object数据,这块内存有一个 ...

  4. LPTHW 笨办法学python 20章

    本章节讲述了,函数和文件的综合操作. 分别 执行了.1.读出文件所有内容,2.把文件重置至文件开头.3.打印一行. 我在本节作了一个小小的改良,设置了一个全局变量,记录当前应该输入哪一行,如果执行过一 ...

  5. sqlite3使用(一)

    最近工作接触到sqlite3了,于是用博客记录下,当然只是浅用哈! 参考资料:http://www.runoob.com/sqlite/sqlite-tutorial.html 概念: SQLite ...

  6. PAT (Basic Level) Practise:1038. 统计同成绩学生

    [题目链接] 本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出. 输入格式: 输入在第1行给出不超过105的正整数N,即学生总人数.随后1行给出N名学生的百分制整数成绩,中间以空格分隔.最 ...

  7. mysql 可能会用到的一些 函数

    DATE_SUB(sysdate(), INTERVAL 8 HOUR)  //当前时间前 8小时 ifnull("","")  Parameter //添加一 ...

  8. 【 D3.js 入门系列 --- 2 】 如何使用数据和选择元素

    接着上一讲的内容,这次讨论如何选择元素和使用数据.    现在页面中有三行文字,代码为: <p>Hello World 1</p> <p>Hello World 2 ...

  9. java导出excel报错:getOutputStream() has already been called for this response

    对于java导出excel报错的问题,查了很多都说是在使用完输出流以后调用以下两行代码即可 out.clear(); out = pageContext.pushBody(); 但这也许是页面上输出时 ...

  10. Web Storage的方法

    1.分为两种:localStorage与sessionStorage.2.存储形式:key-value的形式.sessionStorage 1.session定义:session指用户在浏览某个网站时 ...