Linux Min装机--配置JDK替换OpenJDK

@Linux Min装机--配置JDK替换OpenJDK

 

1.将下载的JDK压缩包解压到/usr/lib/jvm

wil use :

一、文件复制命令cp
    命令格式:cp [-adfilprsu] 源文件(source) 目标文件(destination)
              cp [option] source1 source2 source3 ...  directory
    参数说明:
    -a:是指archive的意思,也说是指复制所有的目录
    -d:若源文件为连接文件(link file),则复制连接文件属性而非文件本身
    -f:强制(force),若有重复或其它疑问时,不会询问用户,而强制复制
    -i:若目标文件(destination)已存在,在覆盖时会先询问是否真的操作
    -l:建立硬连接(hard link)的连接文件,而非复制文件本身
    -p:与文件的属性一起复制,而非使用默认属性
    -r:递归复制,用于目录的复制操作
    -s:复制成符号连接文件(symbolic link),即“快捷方式”文件
    -u:若目标文件比源文件旧,更新目标文件
    如将/test1目录下的file1复制到/test3目录,并将文件名改为file2,可输入以下命令:
    cp /test1/file1 /test3/file2

I use            cp -rf

  

jdk-8uversion-linux-i586.tar.gz
  1. Download the file.

    Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

  2. Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive binary to the current directory.

  3. Unpack the tarball and install the JDK.         (important)

    % tar zxvf jdk-8uversion-linux-i586.tar.gz
    

2.运行以下命令

  1. update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.*/bin/java 1065  
  2. update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.*/bin/javac 1065  
  3. update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.*/bin/jar 1065  
  4. update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.8.*/bin/javaws 1065  


3.然后运行以下命令,并选择你需要的JDK

  1. sudo update-alternatives --config java  
  2. sudo update-alternatives --config javac  
  3. sudo update-alternatives --config javaws

4.(and        )

配置环境变量
如果你机子上面有安装vim的话,请运行vim ~/.bashrc
如果没有的话可以用gedit打开, 请运行gedit ~/.bashrc
在环境变量中添加进以下内容: (Modify by yourself)

export JAVA_HOME=/usr/lib/jvm/java-8*

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH


5

保存环境变量,退出编辑器,然后输入以下命令使环境变量生效

source ~/.bashrc

可以用env命令来查看设置的环境变量是否成功。

6 see the change ,you can use :javac

if succecc and it's ok

    1.   

原文地址:https://www.cnblogs.com/liunnis/p/4678290.html