此内容没有您所选择的语言版本。

A.2. Configure the Default Java Development Kit on Red Hat Enterprise Linux


It is possible to have multiple Java development kits installed on your Red Hat Enterprise Linux system. This task shows you how to specify which one your current environment uses. It uses the alternatives command.

Important

This task only applies to Red Hat Enterprise Linux.

Note

It may not be necessary to do this step. Red Hat Enterprise Linux uses OpenJDK 1.6 as the default option. If this is what you want, and your system is working properly, you do not need to manually specify which Java development kit to use.

Prerequisites

  • In order to complete this task, you need to have superuser access, either through direct login or by means of the sudo command.

Procedure A.2. Configure the Default Java Development Kit

  1. Determine the paths for your preferred java and javac binaries.

    You can use the command rpm -ql packagename |grep bin to find the locations of binaries installed from RPMs. The default locations of the java and javac binaries on Red Hat Enterprise Linux 32-bit systems are as follows.
    Table A.1. Default locations for java and javac binaries
    Java Development Kit Path
    OpenJDK 1.6
    /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
    /usr/lib/jvm/java-1.6.0-openjdk/bin/javac
    Oracle JDK 1.6
    /usr/lib/jvm/jre-1.6.0-sun/bin/java
    /usr/lib/jvm/java-1.6.0-sun/bin/javac
  2. Set the alternative you wish to use for each.

    Run the following commands to set your system to use a specific java and javac: /usr/sbin/alternatives --config java or /usr/sbin/alternatives --config javac. Follow the on-screen instructions.
  3. Optional: Set the java_sdk_1.6.0 alternative choice.

    If you want to use Oracle JDK, you need to set the alternative for java_sdk_1.6.0. as well. Use the following command: /usr/sbin/alternatives --config java_sdk_1.6.0. The correct path is usually /usr/lib/jvm/java-1.6.0-sun. You can do a file listing to verify it.
Result:

The alternative Java Development Kit is selected and active.

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.