JDK 7 : Install2015/03/15 |
|
Install Java SE Development Kit 7 (JDK7) and build Java Environment.
|
|
| [1] | Download and install JDK 7. Make sure the latest version and source URL of JDK on Oracle download site. |
|
[root@dlp ~]#
[root@dlp ~]# curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm" rpm -Uvh jdk-7u75-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
[root@dlp ~]#
vi /etc/profile # add follows to the end
export JAVA_HOME=/usr/java/default export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar source /etc/profile
|
| [2] | Create a test program and make sure if it works normally. |
|
[root@dlp ~]#
vi day.java
import java.util.Calendar;
class day {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DATE);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
System.out.println(year + "/" + month + "/" + day + " " + hour + ":" + minute);
}
}
javac day.java # compile [root@dlp ~]# java day # execute 2015/3/15 19:30 |