This article addresses: https://www.cnblogs.com/oberon-zjt0806/p/11663731.html
be reproduced, source, format, understand? ?
What is JDK? ?
Well if you do not know the problem, then I really do not know why you want to install this thing.
JDK (Java Development Kit) is a Sun Microsystems (acquired by Oracle after the) launch of object-oriented programming language 's development kit , and then to have this toolkit we can use the Java language programming and development.
Today we want Linux be deployed under the environment of this thing to be able to develop, and is compressed to extract a way to install, why do not the way rpm installation is mainly to be able to have commonality across all Linux systems, rpm and deb It can only be installed on each Debian and Red Hat's Linux system, but also a problem of mutual conversion, but with the compressed package will not have this problem, although relatively cumbersome number .
Operating System: CentOS Linux Release 8.0.1905 (Core)
Environment: Virtual Box virtual machine
I just want to let Java programs to run on this I do? ?
If you are too lazy to find or not find the JRE installation tutorial, then you the time being can go along with this process down, ensure that your Java program really be able to run , but your Linux operating system will be more out of a lot of you actually absolutely do not need.
If I want to install other versions of it? ?
JDK 8 and below this version may differ, please refer to other specialized installation JDK installation process 8.
JDK 10 should be above the process generally is not much difference, but when the reference position is important to note that some need to replace your current version of the code.
Why do you want to install Linux on it? ? You do not prefer to take the Windows platform Eclipse Java developers do it? ?
Your question really is, ah, you're right, but in the case of special needs, I had to take some "I do not like" behavior.
And this is a, because I need to deploy Hadoop in the Linux platform , and a new installation of CentOS which did not have the Java environment:
[user@localhost /]$ java -version
bash: java: 未找到命令...
The Java SE is a Hadoop is a prerequisite
And if deployed well, then I can do with Linux Java was developed not Miya? ?
But it looks like the same kind of online tutorials very much ah
When did I say this is a tutorial of? ? It's just my time as the process of recording it, if possible, and I hope it can become other people's reference , and I also made reference to many of the installation process, eventually I succeeded a.
Standing on the shoulders of countless giants.
Well, not much to say, it would begin.
Ah, indeed. You first need to install a Linux system , no need is CentOS, can also be Ubuntu, Fedora, Debian or something as you like , with no GUI also does not matter , because even though I installed CentOS with a GUI, my actual installation process It is on a bash instruction completion of.
Prior to the actual installation, I had to explain in advance :
And not the same as Windows, Linux systems are case-sensitive , which means that
/Somewhere/a.zip
and/somewhere/A.zip
are not in the same directory , it is not the same file name , to this point is important to note ! ! !
The real content of all shell commands appear below are from the$
beginning after.
As you are physical machines or virtual machines this distinction should not , you can actually take a U disk to install under Box can also be what a VMWare or Virtual. I have not described here.
Download JDK archive
In short, CentOS 8 I installed , of course, you may use the Ubuntu 16.04 What's this casually, and the next from a network to download a JDK13 archive ( jdk-13_linux-x64_bin.tar.gz
)
It is assumed that you either download or GUI
wget
way to download, you have to download the compressed package/usr/download
under the directory
If your Linux system has a GUI and system pre-installed Firefox , then you can like in Windows as rushed rushed to get the JDK Download Firefox, like this:
If there is no GUI, you can use the wget
command:
[user@localhost /usr/lib/jvm/jdk-13]$ su root # 整个过程需要提升为root权限进行,因为普通用户不可以在usr、etc文件夹及它们的子文件夹下进行修改
[root@localhost /]$ mkdir /usr/download # 如果你没有这个目录的话就先键入这个指令,否则直接看下一句
[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 Oracle's official website requires logging on to an account in order to download Oracle JDK and other content, so simply type
wget https://download.oracle.com/otn-pub/java/jdk/13+33/5b8a42f3905b406298b72d750b6919f6/jdk-13_linux-x64_bin.tar.gz
Download out
jdk-13_linux-x64_bin.tar.gz
only 5KB ( actually should be 180MB ), something that is simply not compressed but only a page request. So if the above can only be downloaded via the command line by way of download
look good after downloadingjdk-13_linux-x64_bin.tar.gz
attributes:
[root@localhost /]$ ls -al jdk-13_linux-x64_bin.tar.gz
-rw-rw-r--. 1 user user 188711447 9月 19 11:13 jdk-13_linux-x64_bin.tar.gz
In some of the Linux operating system, then position the file name is displayed in red, meaning that:
This is a compressed file
So do not worry, this is not a mistake, you can proceed.
If you find
188711447
(about 180MB) is5307
(about 5KB) (file size that is serious inconsistencies) replaces the download link means you are wrong, please read the contents of the above "attention" inside and then userm jdk-13_linux-x64_bin.tar.gz
this file to delete and re-download, but if the size is inconsistent almost very likely that you download other versions, there may be damage to the compressed package, if it is the latter, please re-download.
Unzip the file JDK installation package
Next, using the tar command extracting archive extract to /usr/lib/jvm
the 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 #-- 这一步请耐心等待一会,需要一段时间
[root@localhost /usr/download]$ cd /usr/lib/jvm
[root@localhost /usr/lib/jvm]$ ls
jdk-13
You will see /usr/lib/jvm
the presence of a known jdk-13
file folder, we go in and see
[root@localhost /usr/lib/jvm]$ cd jdk-13
[root@localhost /usr/lib/jvm/jdk-13]$ ls
bin conf include jmods legal lib man release
So far, all the components have been JDK get ready, the next to be configured.
Adding Environment Variables
Note : This requires the use of VIM
- If you use VIM
- Ah, that is no problem, keep going
- If you do not use VIM
- If you use a Linux system with a GUI interface
- You can use the preinstalled text editor to edit, just as in Windows using Notepad inside.
- otherwise
- If you want to know VIM
- Find other people to look at VIM tutorial on basic operations
- Otherwise, if you have a trusted friend and is robust enough words
- Looking for him to help you Nongnong
- otherwise
- emmm ...... I hereby sincerely feel sad for you
Use the installer in the Windows installation when the general environment variables are automatically configured, but unfortunately we are now manually installed, JDK's a lot of jobs depend on the path environment variable.
Software like Oracle system are the pair of sub-sub-die, such as Oracle DB ......
JDK need a few environment variables:
JAVA_HOME
: Java home directory, you get compression bag after extractingjdk-13
the folder where the position (and containjdk-13
itself)JRE_HOME
: The home directory of the JRE, JRE is the most basic software environment to run Java applications, so if you just want to be able to run Java programs, then you absolutely do not need to install JDK, although there JDK with JRE.CLASSPATH
: Java provides a standard location or public libraryPATH
: This is the system environment variables, this thing is just to tell the system your Java development environment is installed in what position, this thing is the development of tools that you can execute directly Java in any directory such asjavac
etc., simply typejavac
can be performed while no need to retype/usr/lib/jvm/jdk-13/bin/javac
.
Linux system environment variables are stored in several files, their scope is different, and some only apply to the current user, while others act on all users. And our environment here directly to all users take effect on it (because in additionroot
I am a useruser
), so here we will/etc/profile
be modified.
But we now knowJAVA_HOME=/usr/lib/jvm/jdk-13
, this means that the directory contains the Java Runtime Environment and everything related, are what we look inside
[user@localhost /usr/lib/jvm/jdk-13]$ ls
bin conf include jmods legal lib man release
Which bin
is all Java development tools (usually an executable application) directory is located, and lib
which is the Java class libraries provided by the public, of course, this is what we are looking for CLASSPATH
a.
So, JRE_HOME
how to do it? ?
As early as when JDK 8, installed JAVA_HOME
next to find a named jre
file folder, but that time is just also saw JDK 13, where jre
it? ?
In fact, we do not consider this issue, not only because the new version of the JDK comes with JRE, the JRE and JDK components directly into ruin, so JRE_HOME
you can directly into JAVA_HOME
it.
So we open with VIM /etc/profile
(because it is) for editing:
[root@localhost /usr/lib/jvm/jdk-13]$ vim /etc/profile
By adding the following at the beginning of this file:
export JAVA_HOME=/usr/lib/jvm/jdk-13
export JRE_HOME=/${JAVA_HOME}
export CLASSPATH=.:${JAVA_HOME}/libss:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Then :wq
save and exit, but because it is only written in the document, these environmental variables were not actually built into the kernel, so you need to manually perform about this file.
[root@localhost /usr/lib/jvm/jdk-13]$ source /etc/profile
[root@localhost /usr/lib/jvm/jdk-13]$ exit #退出root权限
At this point, the installation process all over, JDK can work properly, we can test it with the following command:
[user@localhost /usr/lib/jvm/jdk-13]$ java -version
Now we can use JDK13 on a Linux system is developed.
Since installed, we may wish to try it!
Yes! ! We have been gearing up, and then write a Java program to test it!
Just build a file folder in a position to write a Hello World Give it a try:
[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.java
public class Hello
{
public static void main(String args[])
{
System.out.println("Hello");
}
}
[user@localhost ~/jsrc]$ javac Hello.java
[user@localhost ~/jsrc]$ ls
Hello.class Hello.java
[user@localhost ~/jsrc]$ java Hello
Hello
Ah, finally ...
fun! !
Of course, then I will be the same record more stuff Hadoop installation process and so on, so stay tuned! !
the above.