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

How to install jdk in a linux server

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

Share

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

This article is to share with you about how to install jdk in the linux server, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

First, get a linux server

To install jdk under linux, you must first have a linux server. As rookies, all the machines on hand must belong to windows. It is excruciating for a rookie like me to install a virtual machine. Here, the easiest way to get a linux server is to rent one from Aliyun. Select CentOS7.3 64-bit for the image.

II. Install jdk for yum

Using yum installation on linux is very rude and brainless, but there are still points to pay attention to, otherwise you will fall into the hole. Here are the steps.

1. Execute the command yum-y list java* to view the installable java version. After a successful execution, you can see the following results

two。 Choose a version of java to install, here we want to install java1.8, because our machine is 64-bit, so choose to install java-1.8.0-openjdk-devel.x86_64.

One thing to note here is that the two java versions I circled in red boxes above should choose the installation of-devel, because this installation is jdk, while the one without-devel is actually jre.

3. Execute the command yum install-y java-1.8.0-openjdk-devel.x86_64. After execution, you will see that the console brushes a lot of output.

Wait patiently until the automatic installation is complete

4. Type java-version to view the installed version of jdk. The following output indicates that the installation is successful.

5. You may wonder, where is the jdk installed by yum? You can find them in the / usr/lib/jvm directory.

At this point, the yum installation jdk is complete.

Download the package and install jdk from the official website

If you don't like the way yum is installed, and want to use the official installation package for traditional installation, you can use the following steps.

1. Execute the command useradd java to create a new user java

two。 Execute the command passwd java to set the java user password

3. Go to the official website of oracle and download page http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html of java8.

You can also choose the corresponding version through the download of

4. Select Accept License Agreement, click jdk-8u131-linux-x64.tar.gz to get the download link. Note that the download link obtained is time-limited (it is not clear how long it will be valid, but it certainly cannot be used the next day). Please copy it to linux as soon as possible.

5. Enter the / home/java directory and enter the wget + address to start the download.

6. Wait for the download to succeed

7. Check the file and find that the downloaded file name has a strange suffix. Rename the downloaded file.

8. Enter the command tar zxvf jdk-8u131-linux-x64.tar.gz to extract the installation package

9. Enter the command vim / etc/profile to open the environment variable configuration file

Enter the following information at the bottom of the file and save

JAVA_HOME=/home/java/jdk1.8.0_131JRE_HOME=$JAVA_HOME/jrePATH=$PATH:$JAVA_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport JRE_HOMEexport PATHexport CLASSPATH

10. Enter the command source / etc/profile to refresh the environment variable configuration file to take effect immediately; enter java-version to view the installed jdk version

If you think it's done, you're in the pit. Although this is enough most of the time, there is one more step you'd better do. Create a hyperlink to / usr/bin/java 's java.

Ln-s / home/java/jdk1.8.0_131/bin/java / usr/bin/java

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.

The above is how to install jdk in the linux server. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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