Увод
Предуслови
Објава
Инсталирање ОпенЈДК 8 пакета
Инсталирање ОпенЈДК 7 пакета
Инсталирање ОпенЈДК 6 пакета
Инсталирање Орацле Јава 8 пакета
О Орацле Јава 7 и Орацле Јава 6 пакетима
Checking installation result
Setting up environment variables
Introduction
Java is a popular software platform that lets you develop and run Java applications and applets in various hardware environments.
There are three editions of the Java platform: Standard Edition (SE), Enterprise Edition (EE), and Micro Edition (ME). We will only talk about the Standard Edition (SE) of Java in this article.
There are also two different implementations of the Java SE platform: OpenJDK and Oracle Java. The source code of each implementation is almost the same, only several minor differences exist between them. In short, OpenJDK is fully open source and primarily GPL-licensed while Oracle Java adds some closed source third party components and some commercial features, using a commercial license - Binary Code License for Java SE Platform Products.
Besides, there are two different packages for each implementation of Java: Java Runtime Environment (JRE) and Java Development Kit (JDK). JRE is necessary for running compiled Java applications while JDK is used for developing Java applications.
Meanwhile, each implementation of Java SE has three widely-used version numbers (6, 7, and 8) for various kinds of applications.
За Орацле Јава, софтверски пакети могу бити 32-битни (и686, к86) или 64-битни (к64).
Када инсталирате Јава СЕ, потребно је да изаберете одговарајућу комбинацију фактора наведених изнад, у складу са захтевима ваших апликација и лиценци.
Предуслови
Све команде у овом водичу треба да покреће корисник који није роот са судо привилегијама. Морате креирати таквог корисника према овом чланку .
Објава
Обично је потребно само да инсталирате само једну од следећих варијанти, али дизајн Јаве вам омогућава да инсталирате две или више варијанти на вашем систему. Након инсталације, требало би да подесите и неколико варијабли окружења за свакодневну употребу. Такође помаже да подесите подразумевани Јава програм када имате више варијанти инсталираних на вашем систему. Упутства су дата касније у овом водичу.
Инсталирање ОпенЈДК 8 пакета
ЈРЕ: sudo yum install -y java-1.8.0-openjdk
ЈДК: sudo yum install -y java-1.8.0-openjdk-devel
Инсталирање ОпенЈДК 7 пакета
ЈРЕ: sudo yum install -y java-1.7.0-openjdk
ЈДК: sudo yum install -y java-1.7.0-openjdk-devel
Инсталирање ОпенЈДК 6 пакета
ЈРЕ: sudo yum install -y java-1.6.0-openjdk
ЈДК: sudo yum install -y java-1.6.0-openjdk-devel
Инсталирање Орацле Јава 8 пакета
За разлику од ОпенЈДК, Орацле Јава пакете треба преузети на ваш систем пре него што их можете инсталирати.
Постоје три различита пакета Орацле Јава 8: ЈРЕ, Сервер ЈРЕ и ЈДК. Међу овим пакетима, Сервер ЈРЕ пакет је за покретање Јава апликација на серверу, друга два се користе на исти начин као и њихови ОпенЈДК вршњаци.
Ако је могуће, увек би требало да преузмете и инсталирате најновију верзију Орацле Јава, која је 8u66у тренутку писања. Увек можете пронаћи најновију верзију и њен УРЛ за преузимање на званичном сајту Орацле Јава.
Остале опције инсталације укључују: типове процесора (и686 или к64) и типове датотека за преузимање ( .rpmили .tar.gz).
ЈРЕ
cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jre-8u66-linux-x64.rpm"
sudo yum localinstall -y jre-8u66-linux-x64.rpm
rm ~/jre-8u66-linux-x64.rpm
Note: If a newer version is released, replace the URL and the file name accordingly with the latest info on the Oracle website.
Server JRE
cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u66-b17/server-jre-8u66-linux-x64.tar.gz"
sudo mkdir /usr/java/
sudo tar -zxvf server-jre-8u66-linux-x64.tar.gz -C /usr/java/
rm ~/server-jre-8u66-linux-x64.tar.gz
Note: If a newer version is released, replace the URL and the file name accordingly with the latest info on the Oracle website.
Before you can use Java, you need to set up several environment variables:
sudo vi /etc/profile
Add the following sentences to the end of the file:
export JAVA_HOME=/usr/java/jdk1.8.0_66
export JRE_HOME=/usr/java/jdk1.8.0_66/jre
export PATH=$PATH:/usr/java/jdk1.8.0_66/bin
Save and quit:
:wq
Put your changes into effect:
source /etc/profile
JDK
cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm"
sudo yum localinstall -y jdk-8u66-linux-x64.rpm
rm ~/jdk-8u66-linux-x64.rpm
Note: If a newer version is released, replace the URL and the file name accordingly with the latest info on the Oracle website.
About Oracle Java 7 and Oracle Java 6 packages
The security updates of Oracle Java 7 and Oracle Java 6 have been unavailable to the public for a while now. It's not recommended to continue the use of Oracle Java 7 or Oracle Java 6 without these security updates. If you are obligated to maintain an incompatible-to-Oracle-Java-8 legacy Java 7 or Java 6 application, you need to contact Oracle for further support.
Checking installation result
java -version
If your installation is OK, you will see a prompt like:
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
Подешавање променљивих окружења
Коју год варијанту да сте инсталирали, требало би да подесите следеће променљиве окружења за свакодневну употребу. Када је више варијанти инсталирано на вашем систему, такође можете одредити подразумевани Јава програм на следећи начин:
sudo vi /etc/profile
Додајте следеће реченице на крај датотеке. Замените /usr/java/jdk1.8.0_66са локацијом за инсталацију на вашем серверу:
export JAVA_HOME=/usr/java/jdk1.8.0_66
export JRE_HOME=/usr/java/jdk1.8.0_66/jre
export PATH=$PATH:/usr/java/jdk1.8.0_66/bin
Сачувај и затвори:
:wq
Ставите своје промене на снагу:
source /etc/profile