How to manually install Java on Linux

Monster_ take off 2022-01-26 14:40:57 阅读数:330

manually install java linux

Use Linux The software package management tool of the distribution to install Java software package It's easy . However , Sometimes you need to install it manually Java. This pair is based on Java Application server ( Such as Tomcat or JBoss) Your administrator is particularly important . Many open source and proprietary software products rely on these services .

 Insert picture description here
How to be in Linux Manual installation on Java
Use Linux The software package management tool of the distribution to install Java software package It's easy . However , Sometimes you need to install it manually Java. This pair is based on Java Application server ( Such as Tomcat or JBoss) Your administrator is particularly important . Many open source and proprietary software products rely on these services .

Manual installation can give users better control Java Runtime environment .

Use Linux The software package management tool of the distribution to install Java software package It's easy . However , Sometimes you need to install it manually Java. This pair is based on Java Application server ( Such as Tomcat or JBoss) Your administrator is particularly important . Many open source and proprietary software products rely on these services .

Developer or runtime Suite ?

Java virtual machine Java Virtual Machine(JVM) Provide... In two different forms :Java Development kit Java Development Kit(JDK) or Java Runtime environment Java Runtime Environment(JRE).

Software developers often need JDK. It includes compilation 、 Binary files required to run and test the source code . Deploy a pre-established Java Applications usually only need JRE. It does not include compilers and other development tools . Due to the improvement of security and the limitation of space , Usually installed in a production environment JRE.

obtain Java

You can download open source from the Internet Java Software . You can Red Hat Developer、Adoptium.net download OpenJDK Package files , Or from Azul download Zulu Community Edition .

install Java

Set up a directory to store Java file . I like to create a simple one called java The catalog of , So I can download and unzip the package file in a special directory :

$ mkdir -p java/jdk

Let's use... In this example JDK. Save the downloaded file to jdk Under the table of contents . Then change to this directory :

$ cd java/jdk
$ ls
OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz

Extract the packaged file . Be careful ,tar A new directory will be created :

$ tar xvzf OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz
$ ls
jdk-11.0.12+7 OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz

Use -version Option confirmation NEW JVM Version of .

$ cd jdk-11.0.12+7/bin
$ ./java -version

JVM The version output of looks like this :

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)

environment variable

To ensure that a particular application works , It needs to know exactly how to locate JVM. There are two main variables that need to be set :JAVA_HOME and PATH.

$ echo $JAVA_HOME
$ echo $PATH

These can be found in the user's .bashrc Set in file . Make sure these variables appear in Any settings PATH Existing code for after :

#Set the JAVA_HOME
export JAVA_HOME=~/java/jdk/jdk-11.0.12+7
#Add the JAVA_HOME to the PATH
export PATH="$JAVA_HOME/bin:$PATH"

Manual installation

There are several situations that require manual installation Java. Please consider the following three situations :

One situation may require the use of different , Maybe earlier , In your Linux The software library of the distribution is no longer available Java edition .

Another example might be a security driven decision , namely Java It will not be installed on the operating system by default or on “ Root level ” On .

The third case is that several different versions of Java, Usually because J2EE Web Multiple instances of the application run on the same server . With the increasing use of virtual machines and containers to isolate processes , This kind of operating system sharing is not very common today . However , Due to the need to maintain different container images , The understanding of manual installation is still crucial .

summary

I demonstrated that I manually installed Java How the runtime environment , But you can make a convention that best suits your needs . Final , Manual installation gives users better control Java Runtime environment .

copyright:author[Monster_ take off],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/01/202201261440551608.html