(2)Linux Java环境变量安装
- install default JRE/JDK
- Installing Java with
apt-get
is 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-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 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_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:
- 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环境变量. ...
随机推荐
- AC3 mantissa quantization and decoding
1.overview 所有的mantissa被quantize到固定精确度的level(有相应的bap标识)上,level小于等于15时,使用symmetric quantization.level大 ...
- 微信小程序 - height: calc(xx - xx);无效
遇到一个小问题,记录一下 问题:在微信小程序中使用scroll-view标签时,用height:cale(xx - xx)设置高度无效,在page中设置高度为百分百依旧无效 解决办法:直接在父级vie ...
- C++11 Lambda函数
Lambda函数 C++11新增了lambda函数,其基本格式如下 [捕捉列表] (参数) mutable -> 返回值类型 {函数体} 说明 []是lambda的引出符,捕捉列表能够捕捉上下文 ...
- 7_1 除法(UVa725)<选择合适的枚举对象>
如果把数字0到9分配成2个整数(各五位数),现在请你写一支程序找出所有的配对使得第一个数可以整除第二个数,而且商为N(2<=N<=79),也就是:abcde / fghijk = N这里每 ...
- DataTable、DataRow、DataColumn用法
转载csdner 发布于2018-08-17 17:03:30 阅读数 4375 收藏 DataSet 表示数据在内存中的缓存. 属性 Tables 获取包含在 DataSet 中的表的集合. ...
- SqlDataReader阅读器关闭时尝试调用 HasRows 无效
SqlDataReader阅读器关闭时尝试调用 HasRows 无效 原创长白山上放羊娃 发布于2018-07-25 00:29:27 阅读数 538 收藏 展开 在SqlHelper中封装好的Sq ...
- 6月28日至7月6日第一周小学期学习c++编程收获
6.28日开始,进入小学期,也就是在10天十天时间内集中练习,以提高编程能力.此次小学期的作业共有十道题,其中分为四大类,系统类,数学类,游戏类,链表类. 我开始的时候面对第一,二题,系统类,因为当时 ...
- ACM-ICPC实验室20.2.21测试-图论(二)
A.患者的编号 给出一个有向图,要求你输出字典序最小的拓扑排序. 常规拓扑排序是做不了的,正解是反向建图,同时用大根堆的优先队列维护,保证每次优先访问编号大的结点,再反向输出~ #include< ...
- 09day vi命令详解
vi有三种模式(互相切换) 1. 命令模式 2. 插入模式(编辑模式) 3. 低行模式 三种模式的切换方法: 使用技巧 vi 文件信息 i --- 进入编辑模式 esc --- 退出编辑模式 :wq ...
- Java查询数据库
创建数据库 创建 user 数据库 创建 teacher 数据库 teacher表的user_id列与user表的id列建立一对多连接,user_id作为外键. Java编程查询数据库 向user数据 ...