The Ubuntu system does not have a Java environment installed by default and is not installed when running Javac:
$ javacthe Program ' Javac ' can is found in the following packages: * DEFAULT-JDK * ECJ * GCJ-5-JDK * openjdk-8-jdk-headles S * GCJ-4.8-JDK * GCJ-4.9-JDK * openjdk-9-jdk-headlesstry:sudo apt install <selected package>
Open Oracle website, java
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
Depending on the system selection version, select jdk-8u144-linux-x64.tar.gz(Linux x64 176.92 MB) to download it, then unzip the installation, install it here to/opt/ Under the Jdk-8 directory
Cd/opt/mkdir jdk1.8.0_144cd jdk1.8.0_144/mv/home/muti/downloads/jdk-8u144-linux-x64.tar.gz . tar-zxvf jdk-8u144-linux-x64.tar.gz MV jdk1.8.0_144/*.
Then create a new Java environment variable in/etc/profile.
Vim/etc/profile
Fill in the content as follows
Export Java_home=/opt/jdk1.8.0_144export jre_home= $JAVA _home/jreexport classpath=.: $CLASSPATH: $JAVA _home/lib: $JRE _home/libexport path= $PATH: $JAVA _home/bin: $JRE _home/binexport java_home=/usr/jdk1.8.0_144export JRE_HOME= $JAVA _ Home/jreexport classpath=.: $CLASSPATH: $JAVA _home/lib: $JRE _home/libexport path= $PATH: $JAVA _home/bin: $JRE _home/bin
Effective immediately
Source/etc/profile
Check that the installation is correct
Java-version
Output
# Java-versionjava Version "1.8.0_144" Java (tm) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot (tm) 64-bit Server VM (build 25.144-b01, Mixed mode)
Ubuntu Configuration Java Environment