Install JDK in linux and linuxjdk
1. Put the one-click installation script install_JDK.sh and the downloaded jdk1.7 in the same directory and upload it to a directory on the linux server.
Note: The script is used to facilitate one-click installation with other services.
2. Add the execution permission to install_JDK.sh.
# Chmod + x install_JDK.sh
3. Execute the one-click installation script
#./Install_JDK.sh
4. Verify the installation
# Java-version
5. One-click installation script content
#! /Bin/sh
# Retrieving the current path
Mypath = $ (cd $ (dirname $0)/; pwd)
Function main ()
{
# Install jdk
Install_JDK
Sleep 1
Echo "jdk installation is complete"
}
Function Install_JDK ()
{
Jdk_path =/usr/jdk64/
Profile =/etc/profile
Java_home = "export JAVA_HOME =/usr/jdk64/jdk1.7.0 _ 67"
Classpath = "export CLASSPATH =.: \ $ JAVA_HOME/jre/lib/rt. jar: \ $ JAVA_HOME/lib/dt. jar: \ $ JAVA_HOME/lib/tools. jar"
Path = "export PATH =.: \ $ JAVA_HOME/bin: \ $ PATH"
Jdk_exists_path = $ jdk_path/jdk1.7.0 _ 67/
If [-d "$ jdk_exists_path"]; then
Return 1
Fi
If [! -D/usr/jdk64]; then
Mkdir/usr/jdk64
Fi
Tar zxvf $ {mypath}/jdk-7u67-linux-x64.tar.gz-C $ {jdk_path}
Echo $ java_home> $ profile
Echo $ classpath> $ profile
Echo $ path> $ profile
Source/etc/profile
./Etc/profile
Sleep 1
# Printf "check java version global. \ n"
Java-version
}
Main