Install Java SE Development Kit (JDK).
[1] Go Sun download site and Click and next, select "linux", then you can download JDK. Next, upload it on your server by FTP and so on.
[2] Install JDK
[root@www ~]# chmod 700 jdk-6u10-rc2-bin-b31-linux-i586-05_sep_2008-rpm.bin
[root@www ~]# ./jdk-6u10-rc2-bin-b31-linux-i586-05_sep_2008-rpm.bin
##### read terms of use #####
Do you agree to the above license terms? [yes or no]
yes
# accept
###################################
For more information on what data Registration collects and
how it is managed and used, see:
Press Enter to continue.....
Done.
[3] Make test program and verify working.
[root@www ~]# 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);
}
}
[root@www ~]# javac day.java # compile
[root@www ~]# java day # run
2008/8/24 21:34
阅读(1480) | 评论(0) | 转发(0) |