文档章节

如何在Ubunt 14.04 在终端安装 Oracle Java ?

Mable2461
 Mable2461
发布于 2014/08/05 17:46
字数 884
阅读 84
收藏 1

教程网址:https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get 

如果安装报错:add-apt-repository提示命令找不到的话,请移步:http://stackoverflow.com/questions/13018626/add-apt-repository-not-found/16032073#16032073

给出复制原帖内容吧

首先是:安装贴

=========How to install Java on Ubuntu 14.04 With Apt-Get============

As a lot of articles and programs require to have Java installed, this article will guide you through the process of installing and managing different versions of Java.

Installing default JRE/JDK

This is the recommended and easiest option. This will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK 7.

Installing Java with apt-get is easy. First, update the package index:

sudo apt-get update

Then, check if Java is not already installed:

java -version

If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:

sudo apt-get install default-jre

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for exampleApache AntApache MavenEclipse and IntelliJ IDEA execute the following command:

sudo apt-get install default-jdk

That is everything that is needed to install Java.

All other steps are optional and must only be executed when needed.

Installing OpenJDK 7 (optional)

To install OpenJDK 7, execute the following command:

sudo apt-get install openjdk-7-jre

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), execute the following command:

sudo apt-get install openjdk-7-jdk

Installing Oracle JDK (optional)

The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.

You can still install it using apt-get. To install any version, first execute the following commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 6

This is an old version but still in use.

sudo apt-get install oracle-java6-installer

Oracle JDK 7

This is the latest stable version.

sudo apt-get install oracle-java7-installer

Oracle JDK 8

This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.

sudo apt-get install oracle-java8-installer

Managing Java (optional)

When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:

sudo update-alternatives --config java

It will usually return something like this if you have 2 installations (if you have more, it will of course return more):

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

You can now choose the number to use as default. This can also be done for the Java compiler (javac):

sudo update-alternatives --config javac

It is the same selection screen as the previous command and should be used in the same way. This command can be executed for all other commands which have different installations. In Java, this includes but is not limited to: keytooljavadoc and jarsigner.

Setting the "JAVA_HOME" environment variable

To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation:

sudo update-alternatives --config java

It returns something like:

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

The path of the installation is for each:

  1. /usr/lib/jvm/java-7-oracle

  2. /usr/lib/jvm/java-6-openjdk-amd64

  3. /usr/lib/jvm/java-7-oracle

Copy the path from your preferred installation and then edit the file /etc/environment:

sudo nano /etc/environment

In this file, add the following line (replacing YOUR_PATH by the just copied path):

JAVA_HOME="YOUR_PATH"

That should be enough to set the environment variable. Now reload this file:

source /etc/environment

Test it by executing:

echo $JAVA_HOME

If it returns the just set path, the environment variable has been set successfully. If it doesn't, please make sure you followed all steps correctly.

然后是:add-apt-repository:command not found 解决贴子

sudo apt-get install software-properties-common python-software-properties

具体来说就是:

Try to install the packages providing the command:

for <= 12.04

sudo apt-get install python-software-properties

for >= 12.10

sudo apt-get install software-properties-common


© 著作权归作者所有

Mable2461
粉丝 0
博文 45
码字总数 2351
作品 0
烟台
程序员
私信 提问
Ubuntu 14.04 LTS 安装Oracle 11GR2

Ubuntu 14.04 LTS 安装Oracle 11GR2 ,经过几天的研究以及参考网上的说明,终于安装成功了 1.将系统更新到最新: sudo apt-get update sudo apt-get dist-upgrade 2.如果使用的Ubuntu不是桌面...

xiaoxin
2014/06/13
0
1
Ubuntu 14.04 安装 JDK 8,ubuntu14.04

Ubuntu 14.04 安装 JDK 8,ubuntu14.04 第一步,下载Linux版JDK 可以通过访问Oracle官网下载,或者直接通过命令行下载。 lxh@ubuntu:~$ wget -c http://download.oracle.com/otn-pub/java/jd...

youxizhe
2015/02/03
0
2
Ubuntu 安装Oracle Java 7 (JDK)

Oracle Java (JVM/JDK)目前已经不再在Debian/Ubuntu软件源,Oracle已经停止JDL协议,只发布OpenJDK。当然,如果你确实需要Oracle Java,可以从官网下载。 下面是Ubuntu 安装Oracle Java JDK...

枫影Xda
2012/09/02
0
0
运维调试记录:Opendaylight铍版本开发环境搭建流程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaobryant/article/details/73609021 一、系统环境 Ubuntu 14.04 LTS CPU:双核 内存:4GB 二、步骤详解 1....

adoryn
2017/06/22
0
0
Ubuntu中安装Pycharm

一:安装PyCharm前,先配置PyCharm的JDK环境,否则在安装过程中报错。 依次执行以下几条command: 安装过程中会跳出Oracle license对话框,选择接受就是了。 安装完成后,运行"java -versio...

winter_kyzg
2017/11/06
0
0

没有更多内容

加载失败,请刷新页面

加载更多

揭秘卷积神经网络热力图:类激活映射

全文共2280字,预计学习时长4分钟 目前在可视化方面,我们已经掌握了许多不同的技术。本文将介绍在卷积神经网络(CNN)中,针对图像的某些部位可视化从而做出判断的不同技术。 类激活映射(CAM)...

读芯术
13分钟前
1
0
阿里云容器Kubernetes监控(九) - Kubernetes事件离线工具kube-eventer正式开源

前言 监控是保障系统稳定性的重要组成部分,在Kubernetes开源生态中,资源类的监控工具与组件百花齐放。除了社区自己孵化的metrics-server,还有从CNCF毕业的Prometheus等等,开发者可选的方...

阿里云官方博客
16分钟前
1
0
Kubernetes Ingress日志分析入门

本文主要介绍如何基于日志服务构建Kubernetes Ingress日志分析平台,并提供一些简单的动手实验方便大家快速了解日志服务相关功能。 部署Ingress日志方案 登录容器服务管理控制台。 将上述CRD...

zhaowei121
20分钟前
1
0
人证核验终端设备

人证核验终端 一、人证核验终端产品简介 人证核验终端是我公司(非思丸智能)自主研发的一款集人脸识别、二代证读卡、OCR、指纹采集的多功能一体机。人证核验终端可读取居民身份证芯片中的身...

非思丸FaceTo
26分钟前
2
0
技术分享 | MySQL 大对象一例

原创作者: 杨涛涛 背景 MySQL 一直以来都有 TEXT、BLOB 等类型用来存储图片、视频等大对象信息。比如一张图片,随便一张都 5M 以上。视频也是,随便一部视频就是 2G 以上。 假设用 MySQL 来...

爱可生
29分钟前
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部