Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of jdk installation and Environment variable configuration in Linux

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the example analysis of jdk installation and environment variable configuration in Linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

It is recommended to use the sudo su command to switch to the root account, otherwise you may not have permission to operate the / opt directory later.

Download and decompress

First go to the official website to download the compressed package jdk-8u144-linux-x64.tar.gz.

After downloading, the terminal type cp jdk-8u144-linux-x64.tar.gz / opt to copy the compressed package to the opt directory

Then go to the opt directory and type tar-zxvf jdk-8u144-linux-x64.tar.gz to extract it.

2. Edit the profile file in the etc directory

Sudo vi / etc/profile uses the vi command to edit the profile file in the / etc directory

Press I to enter edit mode, move the cursor up and down the keyboard to the last line

As shown in the figure, add: export JAVA_HOME=/opt/jdk to the last line

Press the ESC key to exit edit mode and return to command line mode.

Enter: X to save and exit.

Create a java.sh file in the etc/profile.d directory and edit it

Cd / etc/profile.d goes to this directory

Sudo vi java.sh creates the java.sh file and edits (press I to enter edit mode)

Java.sh edits:

(you need to write by path here. First, copy the extracted path under the opt directory and show that the path is / opt/jdk1.8.0_144.)

Export JAVA_HOME=/opt/jdk1.8.0_144export PATH=$PATH:/opt/jdk1.8.0_144/bin

Enter: X to save and exit.

4. Source global configuration file / etc/profile to verify whether the configuration is successful

Source / etc/profile global configuration file (ordinary users switch to root users, to enter this command, the previous configuration steps do not have to be repeated)

Java-version verifies whether the configuration is successful, as shown below:

This is the end of this article on "sample analysis of jdk installation and environment variable configuration in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report