1. Home
  2. Docs
  3. Ubuntu基础设置
  4. Ubuntu 18.4安装配置JDK8运行jar

Ubuntu 18.4安装配置JDK8运行jar

手动下载

下载jdk8(jdk-8u211-linux-x64.tar.gz):https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

在当前用户目录下新建java目录

/home/username/java

将下载的包提取出来,移动至/home/username/java下,即:

/home/username/java/jdk1.8.0_211

配置环境

vi /home/username/.bashrc

添加配置到最后:

export JAVA_HOME=/home/username/java/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH

保存后执行:

source ~/.bashrc

查看版本:

java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

运行jar

java -jar filename.jar
Was this article helpful to you? Yes No