ubuntu install jdk.rpm.bin

本文介绍如何使用RPM包在32位Linux系统上安装Java SE运行环境(JDK)。包括下载文件、使用root权限提取安装文件、删除安装包节省磁盘空间等步骤,并提供了设置浏览器插件的指引。
[size=large]JDK RPM Installation for Linux (32-bit)[/size]


Installation Instructions
This procedure installs the Java SE Runtime Environment for 32-bit Linux, using an RPM binary bundle. Some Linux distributions, such as Ubuntu, are not RPM-based. In that event, please see the self extracting installation page.

The name of the downloaded file has the following format:

jdk-6u

<version>-linux-i586-rpm.bin

<version>
jdk-6u18-linux-i586-rpm.bin
To install, download this file and use the following instructions:

1. Download and check the file size.
[url]http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html[/url]

You can download to any directory that you can write to.
2. Become root by running the su command and entering the root password.

3. Extract and install the contents of the downloaded file.

Change directory to where the downloaded file is located and run these commands to first set the executable permissions and then run the binary to extract and run the RPM file:


                 
% chmod a+x jdk-6u


<version>-linux-i586-rpm.bin
% ./jdk-6u


<version>-linux-i586-rpm.bin



Note that the initial " ./" is required if you do not have " ." in your PATH environment variable.

The script displays a binary license agreement, which you are asked to agree to before installation can proceed. Once you have agreed to the license, the install script creates and runs the file jdk-6u <version>-linux-i586.rpm in the current directory.

NOTE: If you want to only extract the RPM file but not install it, you can run the .bin file with the -x argument. You do not need to be root to do this.

4. Delete the rpm file if you want to save disk space.

5. Exit the root shell.

6. If you want to use Java within the browser, setup the plugin using the instructions in Manual Plugin Installation for Linux.


The RPM package creates two links: /usr/java/latest and /usr/java/default.

The /usr/java/latest link will always point to the version of Java that is considered the latest version. Subsequent upgrades of the package will overwrite this value if it is not the latest version.


By default, /usr/java/default points to /usr/java/latest. However, if administrators change /usr/java/default to point to another version of Java, subsequent package upgrades will be provided by the administrators and cannot be overwritten.
When the JDK is installed, links to javac, jar, and javadoc are also created apart from the JRE links. These links point to the appropriate tool referenced by /usr/java/default. This allows the user to easily run the default version of these Java tools.

A new service script, named jexec, is added to /etc/init.d. This script allows users to directly execute any standalone JAR file that has an execution permission set. This can be demonstrated using an example from the JDK:

cd /usr/java/jdk1.6.0/demo/jfc/SwingSet2
chmod +x SwingSet2.jar
./SwingSet2.jar


[url]http://www.oracle.com/technetwork/java/javase/install-linux-rpm-137089.html[/url]
<think>嗯,用户询问如何在Ubuntu上安装JDK。首先需要明确用户的需求是安装开发环境而不是运行环境。根据引用内容,JDK和JRE的区别很重要,引用[2]明确指出JDK用于编译程序或特定软件要求时使用。 用户可能正在搭建开发环境,比如准备进行Java编程或运行需要JDK的应用程序(如Tomcat)。引用[4]提到Tomcat需要设置JAVA_HOME,这个细节很重要,应该在回复中包含。 安装方案考虑三种主流方式: 1. OpenJDK方案最简便,引用[1]和[3]都提到Ubuntu仓库自带OpenJDK。但要注意引用[3]的提示:某些Linux发行版预装的是OpenJDK 2. Oracle JDK方案适合需要官方版本的情况,引用[5]提供了手动安装的线索,但要注意许可证问题 3. PPA方案作为折中选择,需要提醒用户注意第三方源的安全性 环境变量设置是关键步骤,引用[4]提供的update-java-alternatives命令很实用,比手动配置更可靠。验证部分要设计分层检查:先基础版本,再编译器,最后环境变量。 潜在问题预案: - 多版本共存时优先级处理(引用[4]的-l参数可列出所有安装) - 32/64位系统兼容性(引用[3]提到x86_64环境) - 安装后命令找不到的情况(需要提示注销重登录) 用户可能是开发者或运维人员,回复要突出技术细节但保持操作友好性。相关问题的设计要覆盖后续可能的需求:版本切换、构建工具集成、容器化部署等场景。</think>在 Ubuntu 上安装 JDK (Java Development Kit) 主要有以下几种常用方法: ### 方法 1:安装 OpenJDK (推荐且简便) 这是 Ubuntu 官方仓库提供的开源 JDK 版本,安装最方便,适合大多数开发需求。 1. **更新软件包列表:** ```bash sudo apt update ``` 2. **安装特定版本的 OpenJDK:** * 安装 **OpenJDK 17** (当前最新的 LTS 版本): ```bash sudo apt install openjdk-17-jdk ``` * 安装 **OpenJDK 11** (另一个广泛使用的 LTS 版本): ```bash sudo apt install openjdk-11-jdk ``` * 安装 **OpenJDK 8** (较旧的 LTS 版本,部分旧应用可能需要): ```bash sudo apt install openjdk-8-jdk ``` 3. **验证安装:** ```bash java -version javac -version ``` 命令应分别输出安装的 Java 运行时环境 (JRE) 和编译器 (JDK) 的版本信息。 ### 方法 2:安装 Oracle JDK (官方版本) Oracle JDK 需要手动下载并安装,或通过第三方 PPA 安装。**注意 Oracle JDK 的许可证条款**。 **方法 2A:通过 PPA 安装 (相对简单,但非官方源)** 1. 添加 PPA: ```bash sudo add-apt-repository ppa:linuxuprising/java sudo apt update ``` (此 PPA 由社区维护,请自行评估信任度) 2. 安装 Oracle JDK 17 (或替换版本号): ```bash sudo apt install oracle-java17-installer ``` 安装过程中会弹出 Oracle 许可协议,需要接受。 3. 设置默认 JDK (可选,如果安装了多个版本): ```bash sudo apt install oracle-java17-set-default ``` **方法 2B:手动下载并安装** 1. **下载 Oracle JDK:** * 访问 Oracle JDK 下载页面:[https://www.oracle.com/java/technologies/downloads/](https://www.oracle.com/java/technologies/downloads/) * 选择所需的版本 (如 JDK 17 LTS)。 * 同意许可协议。 * 下载 Linux x64 Compressed Archive (例如 `jdk-17_linux-x64_bin.tar.gz`)。**不要下载 RPM 包**。 2. **创建安装目录并解压:** ```bash sudo mkdir -p /usr/lib/jvm sudo tar -xzvf jdk-17_linux-x64_bin.tar.gz -C /usr/lib/jvm ``` (替换 `jdk-17_linux-x64_bin.tar.gz` 为实际下载的文件名) 3. **配置环境变量:** * 编辑 `~/.bashrc` 文件 (或 `~/.zshrc` 如果你使用 Zsh): ```bash nano ~/.bashrc ``` * 在文件末尾添加以下内容 (替换 `jdk-17` 为实际解压后的目录名): ```bash export JAVA_HOME=/usr/lib/jvm/jdk-17 export PATH=$JAVA_HOME/bin:$PATH ``` * 保存文件 (`Ctrl+O`, 回车) 并退出编辑器 (`Ctrl+X`)。 4. **应用更改:** ```bash source ~/.bashrc ``` 5. **验证安装:** ```bash java -version javac -version ``` 应显示 Oracle JDK 的版本信息。 ### 设置默认 Java 版本 (如果安装了多个 JDK) 1. 使用 `update-alternatives` 查看已安装的 Java 版本及其路径: ```bash sudo update-alternatives --config java ``` ```bash sudo update-alternatives --config javac ``` 2. 系统会列出所有已安装的版本及其路径。输入对应选项前的数字选择默认版本,然后按回车。 ### 验证 `JAVA_HOME` 环境变量 某些应用程序 (如 Tomcat、Maven、Gradle) 需要 `JAVA_HOME` 环境变量指向 JDK 安装目录。 1. 检查 `JAVA_HOME`: ```bash echo $JAVA_HOME ``` 如果安装了 OpenJDK 或通过 PPA 安装了 Oracle JDK 并设置了默认值,`JAVA_HOME` 通常会自动配置。对于手动安装的 Oracle JDK,需要在 `~/.bashrc` 中设置(如方法 2B 所示)。 2. 如果未设置或需要修改,请按照方法 2B 第 3 步编辑 `~/.bashrc` 并设置正确的路径,然后运行 `source ~/.bashrc`。 ### 总结 * **首选 OpenJDK:** `sudo apt install openjdk-17-jdk` (或所需版本) 是最简单、最推荐的方式。 * **需要 Oracle JDK:** 通过 PPA (`sudo apt install oracle-java17-installer`) 安装相对方便,或手动下载安装并配置环境变量。 * **设置默认版本:** 使用 `sudo update-alternatives --config java` 和 `sudo update-alternatives --config javac`。 * **验证 `JAVA_HOME`:** `echo $JAVA_HOME` 确保指向正确的 JDK 目录,这对许多开发工具至关重要[^4]。 [^1]: How To Install Java on Ubuntu with Apt-Get [^2]: There is another default Java installation called the JDK... [^4]: Tomcat needs to know where Java is installed. This path is commonly referred to as "JAVA_HOME"...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值