First, download the installation JDK
Latest version of JDK download address: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Old version of JDK download address: http://www.oracle.com/technetwork/java/javase/archive-139210.html
Depending on the version of the Linux system, 64-bit or 32-bit downloads are available, and two versions of RPM and tar.gz are currently being downloaded.
Note that the gblic version is too old to install the latest JDK. JDK1.7 need glibc2.4 version above.
Rpm-qa | grep glibc or use ldd–version
Installation:
RPM-IVH jdk-7u80-linux-x64.rpm
Two, configure JDK environment variables
Method One: Set a variable under the shell (this method is only valid for the current shell, and if you open another shell, you need to reconfigure it)
Export java_home=/usr/java/ jdk1.7.0_80/
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/ Tools.jar
Method Two: Modify the/etc/profile file (this method is set once and for all users)
to add
Export java_home=/usr/share/at the end of/etc/profile file JDK1.7.0_80
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/ Tools.jar
Perform Source/etc/profile
Method three: Modify. Bash_profile (This method is modified to be valid only for the current user and for all shells of that user)
method ibid. Note open shell to reopen terminal
Test configuration View Java version
[root@oracle cdrom]# java-version
Java versioning ' 1.7.0_80 '
Java ( TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot (tm) 64-bit Server VM (build 24.80-b11, mixed mode)
Indicates that the installation was successful
Third, test JDK
1. Test.java the file with Vim, enter the following code in it, and save:
public class Test {public
static void Main (String args[]) {
System.out.println ("A new JDK test!");
}
2. Compile: Execute command at Shell Terminal Javac Test.java
3. Run: Execute command Java Test at Shell Terminal
"A new JDK test!" appears under the shell. The JDK works fine.
Four, install ant
1, download the latest tar package from http://ant.apache.org/bindownload.cgi: apache-ant-1.6.2.tar.gz
2, install, extract to/usr/ Local under
Tar zxpvf apache-ant-1.6.2.tar.gz
ln-s apache-ant-1.6.2 ant
3, Settings environment
sets Ant_home to the current user's. Bash_ Profile file/home/admin/.bash_profile (or refer to installing JDK on Linux article, modify/etc/profile file)
Modify/etc/profile file
Export ant_home =/usr/local/apache-ant-1.9.6
Export path= $ANT _home/bin: $PATH
Source/etc/profile
4, post-Setup test
Ant
Buildfile:build.xml does not exist!
Build failed
ant-version
ant-version
Apache Ant (TM) version 1.9.6 compiled on June 2015
br>
Five, test ant
1, build Build.xml
<?xml version= "1.0" encoding= "UTF-8"?> <project name= "HelloWorld" "Run" default= "." > <property name= "src" value= "src"/> <property name= "dest value=" classes "/> <property name=" Hello _jar "value=" Hello1.jar "/> <target name=" init "> <mkdir dir=" ${dest} "/> </target> <targe T name= "compile" depends= "init" > <javac srcdir= "${src}" destdir= "${dest}"/> </target> <target N Ame= "Build" depends= "compile" > <jar jarfile= "${hello_jar}" basedir= "${dest}"/> </target> <targe T name= "Run" depends= "Build" > <java classname= "Test.ant.HelloWorld" classpath= "${hello_jar}"/> </target > <target name= "clean" > <delete dir= "${dest}"/> <delete file= "${hello_jar}"/> </ta rget> <target name= "rerun" depends= "Clean,run" > <ant target= "clean"/> <ant "Run" target=
T </target> </project>
2, Java source code
Package test.ant;
public class HelloWorld {public
static void main (String []args) {
System.out.println ("Hello World");
}
Six. Uninstall JDK
Locate the _uninst subdirectory of the JDK installation directory
Execute the command at the shell terminal./uninstall.sh can uninstall the JDK.
Rpm-e Jdk-1.7.0_80-fcs