(2)Linux Java环境变量安装
- install default JRE/JDK
- Installing Java with
apt-getis easy. First, update the package index:- sudo apt-get update
- 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 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 example Apache Ant, Apache Maven, Eclipse 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 Java with
- 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-propertiessudo add-apt-repository ppa:webupd8team/javasudo apt-get update
- Then, depending on the version you want to install, execute one of the following commands:
- Oracle JDK6:This is an old version but still in use.
sudo apt-get install oracle-java6-installer
- Oracle JDK7:This is the latest stable version.
sudo apt-get install oracle-java7-installer
- Oracle JDK8: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
- Oracle JDK6:This is an old version but still in use.
- 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):
- 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
- Setting the "JAVA_HOME" environment variable(取得Java安装路径,设置Java环境变量)
- To set the
JAVA_HOMEenvironment 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:
- The path of the installation is for each:
/usr/lib/jvm/java-7-oracle/usr/lib/jvm/java-6-openjdk-amd64/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.)
- To set the
- 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:
- 通过URL链接安装jdk1.8
- wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
sudo mkdir /usr/java
sudo tar zxf jdk-8u91-linux-x64.tar.gz -C /usr/java
sudo echo "export JAVA_HOME=/usr/java/jdk1.8.0_91" >> /etc/bashrc
sudo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/bashrc
sudo echo "export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/bashrc
source /etc/bashrc
- wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
(2)Linux Java环境变量安装的更多相关文章
- [知了堂学习笔记]_牵线Eclipse和Tomcat第一篇 —— 配置Java环境变量&&安装eclipse
一.先给他们提供一个"浪漫的"环境,比如传说中的"鹊桥"--java环境变量.哈哈! 配置java环境变量. 下载jdk,根据自己电脑的版本和操作位数选择不同的 ...
- linux java环境变量设置
下载JRE或者JDK后解压,设置以下环境变量 JAVA_HOME=/home/zm/jdk1.8.0_181JRE_HOME=/home/zm/jdk1.8.0_181/jreCLASSPATH=.: ...
- JAVA环境变量安装
需配置的系统环境变量参数: JAVA_HOME:C:\Program Files\Java\jdk1.8.0_60 CLASS_PATH: ;%JAVA_HOME%\lib;%JAVA_HOME%\l ...
- Linux Java 环境变量设置
对整个机器:所有用户 1,在/etc/profile 文件末尾加入 export JAVA_HOME=/var/opt/jdk1.7.0_04 export PATH=$JAVA_HOME/bin:$ ...
- Linux中如何设置java环境变量
这里介绍Linux下如何设置java环境变量. 工具/原料 Linux java环境变量 方法/步骤 1 查看java的安装路径 查看java执行路径 配置java环境变量 java的安装 ...
- JDK的安装与配置java环境变量
JDK安装与配置java环境变量 安装JDK 1.百度搜索jdk8找到下载地址 下载地址:Java SE Development Kit 8 - Downloads (oracle.com) 2.点击 ...
- linux配置java环境变量(详细)
linux配置java环境变量(详细) 本文完全引用自: http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 一. 解压安装jdk ...
- linux配置java环境变量
linux配置java环境变量(详细) 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录, 执行命令 ./jdk-6u14-linux-i586. ...
- 14行脚本配置Linux下一个Java环境变量
供Java人们刚开始学习.多半Java它需要花费大量的精力在开发环境的配置,于Linux下一个,构造Java环境变量,很可能加入这一努力. 为此,我做了一个bash脚本来配置自己主动Java环境变量. ...
随机推荐
- Ninject 2.x细说---1.基本使用
Ninject 2.x细说---1.基本使用 https://blog.csdn.net/weixin_33809981/article/details/86091159 本来想使用一下Ninje ...
- 【音乐欣赏】《紅蓮華》 - LiSA
曲名:紅蓮華 作者:LiSA [00:00.92]強くなれる理由を知った [00:07.34]僕を連れて 進め [00:18.74]泥だらけの走馬灯に酔う [00:24.37]強張る心 震える手は [ ...
- zabbix4.2安装配置指南
[声名]本实例中采用Linux CentOS 7系统 CentOS Linux release 7.6.1810 (Core) 1.安装LAMP环境: [root@localhost /]# yum ...
- How To Use These LED Garden Lights
Are you considering the lighting options for the outdoor garden? Depending on how you use it, LED ga ...
- Vue - 过渡 列表过渡
列表的进入/离开过渡 获取不大于数组长度的随机数,作为插入新值的位置 <div id="app" class="demo"> <button ...
- 【做题笔记】P1969 积木大赛
非常感谢 rxz 大佬提供的思路. 首先放个图(rxz 画的) 采用贪心的策略:对于一个期望高度 \(h_i\) ,如果大于 \(h_{i-1}\),那么最终答案要加上二者之差:如果小于或等于,那么说 ...
- C语言随笔3:指针定义、数据在地址中的大小端排列
指针变量:用于存放另一个变量的地址 (指针变量所占空间大小由操作系统决定32/64位 4/8字节 // 声明且定义:int *p=&a: 声明.定义:int *p: p= &a: ...
- Ubuntu 安装 k8s 三驾马车 kubelet kubeadm kubectl
Ubuntu 版本是 18.04 ,用的是阿里云服务器,记录一下自己实际安装过程的操作步骤. 安装 docker 安装所需的软件 apt-get update apt-get install -y a ...
- 使用docker踩过的坑(二)
关于docker的部署,我这里不多说了 下面写一些最近经常用到的命令: docker下载镜像: docker pull 镜像名 docker查看已下载的所有镜像: docker images dock ...
- 有源汇有上下界最小流 (ZQU 1592)
这道题跟求最大流的时候差不多. 都是先构造可行流,然后判断是否可行, 可行的话,就利用残余流量,构造从汇点t跑到源点s的最大流, 如何求出答案呢. 在第一次求可行流的dinic后,跟求最大流的时候一样 ...

