In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to install JDK 13 in a compressed package in a Linux environment. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is JDK?
Well, if you don't know the problem, I really don't know why you installed this thing.
JDK (Java Development Kit) is an object-oriented programming language development kit launched by Sun (later acquired by Oracle). With this toolkit, we can use Java language for program design and development.
Today, we are going to deploy this thing in the Linux environment so that it can be developed and installed in a compressed package. The reason why we do not use rpm installation is mainly to be universal on all Linux systems. Rpm and deb can only be installed on Linux systems under Red Hat and Debian at most, and there will be a problem of conversion between them, but there is no such problem with compressed packages. Although it is relatively cumbersome.
Operating system: CentOS Linux Release 8.0.1905 (Core)
Environment: Virtual Box virtual machine
What if I just want the Java program to run on me?
If you are too lazy to find an installation tutorial for JRE, you can follow this process to make sure that your Java program does work, but there will be a lot of things on your Linux operating system that you don't need at all.
What if I want to install another version?
Versions of JDK 8 and below may be different from this. Please refer to other installation procedures that specifically install JDK 8.
JDK 10 or above should not make much difference in this process, but be sure to note that some locations need to be changed to your current version code when referencing.
Why did you install it on Linux? Don't you prefer to use Eclipse for Java development on the Windows platform?
You have a lot of questions, you're right, but in the case of special needs, I have to take some "I don't like" behavior.
And this is one, because I need to deploy Hadoop on the Linux platform, and there is no Java environment in the newly installed CentOS:
[user@localhost /] $java-version
Bash: java: command not found.
And Java SE is a prerequisite for Hadoop.
And if deployed, I can also use Linux to do Java development, wouldn't it be beautiful?
But it seems that there are a lot of similar tutorials online.
When did I say this is a tutorial? This is only as a record of my process, and I hope it can be used as a reference for others if possible, and I have also referred to the installation process of many people, and in the end I succeeded.
Standing on the shoulders of countless giants.
All right, say no more, let's get started.
Well, that's true. First of all, you need to install a Linux system, not necessarily CentOS, but also Ubuntu, Fedora, Debian, whatever you like, it doesn't matter whether you use GUI or not, because even if I install a CentOS with GUI, my installation process is actually done with bash instructions.
Before actually installing, I must state in advance:
Unlike Windows, the Linux system is case-sensitive, which means / Somewhere/a.zip and / somewhere/A.zip are not in the same directory or the same file name, which is important to note!
The real content of all the shell instructions shown below starts after $.
As for whether you are a physical machine or a virtual machine, it should not make much difference. You can actually take a flash drive and install it, or you can install a VMWare or Virtual Box or something. I'm not going to explain here.
Download the JDK package
Anyway, I installed CentOS 8. Of course, you may use Ubuntu 16.04 or whatever. Next, you need to download a JDK13 jdk-13_linux-x64_bin.tar.gz from the network.
This assumes that whether you download GUI or wget, you have downloaded the package to the / usr/download directory.
If your Linux system has GUI and the system is pre-installed with Firefox, you can rush to the download address of JDK with Firefox as you would in Windows, like this:
If there is no GUI, you can use the wget instruction:
[user@localhost / usr/lib/jvm/jdk-13] $su root # the whole process needs to be upgraded to root, because ordinary users cannot make changes under usr, etc folders and their subfolders
[root@localhost /] $mkdir / usr/download # if you don't have this directory, type this command first, or go straight to the next sentence [root@localhost /] $cd / usr/download [root@localhost / usr/download] $wget-- no-cookies-- no-check-certificate-- header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F Oraclelicense=accept-securebackup-cookie "https://download.oracle.com/otn-pub/java/jdk/13+33/5b8a42f3905b406298b72d750b6919f6/jdk-13_linux-x64_bin.tar.gz
Note: because the Oracle official website requires that you must log in to your Oracle account to download JDK and other content, type directly
Wget https://download.oracle.com/otn-pub/java/jdk/13+33/5b8a42f3905b406298b72d750b6919f6/jdk-13_linux-x64_bin.tar.gz
The only jdk-13_linux-x64_bin.tar.gz downloaded is 5KB (actually it should be 180MB), which is not a zip package at all but a request page at all. So if you download it on the command line, you can only download it in the above way.
After downloading, check the properties of jdk-13_linux-x64_bin.tar.gz:
[root@localhost /] $ls-al jdk-13_linux-x64_bin.tar.gz-rw-rw-r--. 1 user user 188711447 September 19 11:13 jdk-13_linux-x64_bin.tar.gz
On some Linux operating systems, the location of the file name is displayed in red, which means:
This is a compressed file
So don't worry, it's not a mistake, you can move on.
If you find that 188711447 (about 180MB) has been replaced by 5307 (about 5KB) (that is, the file size is seriously inconsistent), which means that your download link is wrong, please read the above "attention" in detail and then delete the file with rm jdk-13_linux-x64_bin.tar.gz and download it again. If the size is inconsistent but about the same size, it is possible that you downloaded another version, or the zip package may be damaged. If it is the latter, please download again.
Extract the files in the JDK installation package
Next, use the tar command to extract the package and unzip it to the / usr/lib/jvm directory:
[root@localhost / usr/download] $mkdir / usr/lib/jvm [root@localhost / usr/download] $tar-xf jdk-13_linux-x64_bin.tar.gz-C / usr/lib/jvm #-- Please wait a while for this step. It will take a while [root@localhost / usr/download] $cd / usr/lib/jvm [root@localhost / usr/lib/jvm] $lsjdk-13
You will see that there is a folder called jdk-13 under / usr/lib/jvm. Let's go in and have a look.
[root@localhost / usr/lib/jvm] $cd jdk-13 [root@localhost / usr/lib/jvm/jdk-13] $lsbin conf include jmods legal lib man release
At this point, all the components of JDK are ready, and the next step is to configure.
Add environment variabl
Note: VIM is required here
If you can use VIM
Ah, that's no problem. Go ahead.
If you can't use VIM
If you are using a Linux system with a GUI interface
You can edit it using a pre-installed text editor, just like using notepad in Windows.
otherwise
If you want to know about VIM,
Look for other people's tutorials to see the basic operation of VIM.
Otherwise, if you have a trustworthy and capable friend
Ask him to help you with it.
otherwise
Emmm... I sincerely feel sorry for you.
Environment variables are generally configured automatically when installing using the installer under Windows, but unfortunately we are now installing manually, and JDK's work depends on the paths in a large number of environment variables.
It seems that all the software of the Oracle department is this dead sub-son, such as Oracle DB.
JDK requires several environment variables:
JAVA_HOME: the home directory of Java, the location where the jdk-13 folder you unzipped the package is located (and contains jdk-13 itself)
JRE_HOME:JRE 's home directory, JRE is the most basic software environment for running Java applications, so if you just want Java programs to run, you don't need to install JDK at all, even though JDK comes with JRE.
The location of the standard or common class library provided by CLASSPATH:Java
PATH: this is the system's environment variable, this thing just tells the system where your Java development environment is installed, this thing allows you to directly execute Java development tools such as javac in any directory, and you can type javac directly without having to retype / usr/lib/jvm/jdk-13/bin/javac.
The environment variables under the Linux system are stored in several files, and their scope of action is different, some only for the current users, and some for all users. Our environment here is valid for all users directly (because I am the only user user besides root), so here we will modify / etc/profile.
But now we know that JAVA_HOME=/usr/lib/jvm/jdk-13, this directory means that it contains everything related to the Java runtime environment, let's see what's in it.
[user@localhost / usr/lib/jvm/jdk-13] $lsbin conf include jmods legal lib man release
Where bin is the directory where all the development tools (usually executable applications) of Java are located, and lib is the common class library provided by Java, of course, this is the CLASSPATH we are looking for.
So, what about JRE_HOME?
As early as in JDK 8, you can find a folder called jre under the installed JAVA_HOME, but I just looked at it when I went to JDK 13. Where is jre?
In fact, you don't have to think about this, because the new version of JDK not only comes with JRE, but also destroys JRE components directly into JDK, so JRE_HOME can be directly given to JAVA_HOME.
So we use VIM to open / etc/profile (because it is) for editing:
[root@localhost / usr/lib/jvm/jdk-13] $vim / etc/profile
Add the following at the beginning of the file:
Export JAVA_HOME=/usr/lib/jvm/jdk-13export JRE_HOME=/$ {JAVA_HOME} export CLASSPATH=.:$ {JAVA_HOME} / libss:$ {JRE_HOME} / libexport PATH=$ {JAVA_HOME} / bin:$PATH
Then: wq saves and exits, but because it is only written in the file, these environment variables are not actually built into the kernel, so you need to execute the file manually.
[root@localhost / usr/lib/jvm/jdk-13] $source / etc/profile [root@localhost / usr/lib/jvm/jdk-13] $exit # log out of root permissions
At this point, the installation process is all over, and JDK can work properly. We can verify it with the following instruction:
[user@localhost / usr/lib/jvm/jdk-13] $java-version
Now we can use JDK13 for development on the Linux system.
Now that it's installed, we might as well give it a try.
You're right! We have already rubbed our hands, so let's write a Java program to test it.
Set up a folder somewhere and write a Hello World. Try it:
[user@localhost / usr/lib/jvm/jdk-13] $mkdir ~ / jsrc [user@localhost / usr/lib/jvm/jdk-13] $cd ~ / jsrc [user@localhost ~ / jsrc] $vim Hello.java/// Hello.javapublic class Hello {public static void main (String args []) {System.out.println ("Hello");} [user@localhost ~ / jsrc] $javac Hello.java [user@localhost ~ / jsrc] $lsHello.class Hello.java [user@localhost ~ / jsrc] $java HelloHello
Thank you for reading! This is the end of this article on "how to install JDK 13 in a compressed package in the Linux environment". 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, you can 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.