Linux下软件环境安装(7)-java安装与配置

下载的ubuntu-18.04.1-live-server-amd64不知道怎么就live了,先看看有没有
java -version
显然没有http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
虽然java10都有了,先下Java SE Development Kit 8u181吧,jdk-8u181-linux-x64.tar.gz大概177MB

tar -zxvf jdk-8u181-linux-x64.tar.gz
sudo mv jdk1.8.0_181 /opt/jdk
sudo vi /etc/profile

在末尾添加配置信息

# JDK,TOMCAT,ORACLE
export JAVA_HOME=/opt/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin

重新加载配置或重起后检验

source /etc/profile   
java -version

搞定!

public class HelloWorld
{
  public static void main( String[] args )
  {
    System.out.println( "Hello, MikuQ!\n" );
    System.exit(0);
  }
}

编译执行

javac HelloWorld.java
java HelloWorld

建立打包文件manifest.mf

Manifest-Version: 1.0
Main-Class: HelloWorld

打包,执行

jar cvfm Hello.jar manifest.mf ./HelloWorld.class
java -jar Hello.jar

先这些吧

https://blog.csdn.net/huanhuanq1209/article/details/72673015
https://blog.csdn.net/gogdizzy/article/details/7196146

标签: none

添加新评论