今天为 centos 5.3 服务器安装jdk, 如果你要开发,运行 java 程序,jdk 是必不可少的。
如果不开发,也就是不用编译java程序,那么只安装jre就可以了。
我这里进行 JDK 安装, 目前为止 jdk 1.7 版本为最新版本吧,1.5 叫做jdk5.0
我不知道 jdk1.7 是否叫做 jdk 7.0 呵呵。
下载站点:
http://download.java.net/jdk7/binaries/
Linux Platform
Linux RPM in self-extracting JDK file
jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin, 59.64 MB
由于文件比较大,我就不提供下载了,
http://www.java.net/download/jdk7/binaries/jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
这个就是完整的下载路径,
如果路径更新不能用了,建议去
http://download.java.net/jdk7/binaries/ 重新找到对应的文件下载。
我已经下载好了,下面传送到 Linux 上面去。
我xp系统是 192.168.1.5
所以 wget http://192.168.1.5:2000/jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
比较郁闷一件事, CentOS5.3没有 wget 这个工具,看来要自己安装了。
]# yum -y install wget
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
* addons: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
base | 1.1 kB 00:00
primary.xml.gz | 878 kB 00:14
base 2508/2508
updates | 951 B 00:00
primary.xml.gz | 135 kB 00:02
updates 207/207
addons | 951 B 00:00
primary.xml.gz | 157 B 00:00
extras | 1.1 kB 00:00
primary.xml.gz | 90 kB 00:01
extras 298/298
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package wget.i386 0:1.10.2-7.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================
Package Arch Version Repository Size
===================================================================
Installing:
wget i386 1.10.2-7.el5 base 581 k
Transaction Summary
===================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 581 k
Downloading Packages:
wget-1.10.2-7.el5.i386.rpm | 581 kB 00:09
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : wget [1/1]
Installed: wget.i386 0:1.10.2-7.el5
Complete!
===================
好了,安装好了 wget 我们继续
wget http://192.168.1.5:2000/jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
]# gcc -v 检查是否存在gcc
]# rpm -qa | grep yacc 检查 yacc 有没有装
]# chmod +x jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
]# ./jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
Do you agree to the above license terms? [yes or no]
最后输入 yes 进行安装 , 由于我刚才复制文本了出现问题,重新安装。
Checksumming...
yeExtracting...
UnZipSFX 5.52 of 28 February 2005, by Info-ZIP (http://www.info-zip.org).
inflating: jdk-7-ea-lin
Preparing... #################################### [100%]
1:jdk ##################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Done.
安装完毕。
[root@localhost usr]# ls /usr/java/
default jdk1.7.0 latest
看到了吧。
配置 java 环境参数
]# vi ~/.bash_profile 修改成这样
JAVA_HOME=/usr/java/jdk1.7.0
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH JAVA_HOME CLASSPATH
保存退出,如果输入 java 和 javac 可以正常运行就可以了。
下面编写一个 HelloWorld.java 文件 进行测试,呵呵。很久没有写过 java 程序了。
public class HelloWorld
{
public static void main( String args[] )
{
System.out.println( "HelloWorld!!" );
}
}
[root@localhost /]# vi HelloWorld.java
[root@localhost /]# javac HelloWorld.java
[root@localhost /]# java HelloWorld
HelloWorld - www.17rumen.com
注意使用 rm -rf 命令,看清楚目录。
[root@localhost opt]# rm -rf *
一切正常, 清空刚才没用的文件。。。
好了 ,今天演示到这里,谢谢大家观看!!!!
05月 30th, 2009 at 23:58:25 #欢乐
为什么现在教程下载不了,我一点下载就是空白的,用讯雷也是下载不了.
[回复]
05月 31st, 2009 at 11:08:45 #admin
由于视频是放在网络硬盘上面的,所以你要 点击进入 下载页面
下载视频注意:请点击 '下载链接' 进入下载页面后, 再进行下载
[回复]
07月 30th, 2009 at 11:06:41 #bluefoxah
我在用你的方法安装jdk时您提供的下载地址已经失效了,我下载了新版本的jdk,但是用你的命令之后会出现错误。
# chmod +x jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
# ./jdk-7-ea-bin-b58-linux-i586-08_may_2009-rpm.bin
Do you agree to the above license terms? [yes or no]
当我输入yes后就进行不下去了,所以我在后面又加了条命令
rpm -ivh jdk-7-ea-linux-i586.rpm就可以进行了!
[回复]
adminreply on 2009-08-01 07:11:48:
JDK版本可能更新了,谢谢你的回复。
11月 10th, 2009 at 13:22:50 #yzhkpli
楼主您好,我碰到了
java /opt/HelloWorld.java
Error: Could not find main class .opt.HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: .opt.HelloWorld.java
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)
求问是为什么呢?
我的详细经过(比着您文档来的)
http://hi.baidu.com/yzhkpli/blog/item/e4ac999776c3a3027af48014.html
[回复]
adminreply on 2009-11-12 10:01:21:
java /opt/HelloWorld 不用 .java
如果是 javac 则如下 :
javac /opt/helloWorld.java
12月 28th, 2009 at 13:52:24 #匿名
Failed to extract the files. Please refer to the Troubleshooting section of
the Installation Instructions on the download page for more information.
gcc and yacc 都有装.不知道碰见没
[回复]
匿名reply on 2009-12-28 13:56:21:
看到bluefoxah兄的回复发现执行错误后出来了RPM包,于是跟着bluefoxah兄RPM
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
没有done?
匿名reply on 2009-12-28 14:07:08:
HelloWorld!!感谢楼主,继续关注.
PS我是在LAMP基础上测试的,centos5.2升级到5.4,
adminreply on 2009-12-29 11:29:50:
谢谢关注
02月 23rd, 2010 at 15:37:11 #匿名
<!--
- The Resin configuration file.
-
- This example file is more complicated than is needs to be because
- it makes several configurations explicit that can be simplified and
- because it needs to configure the examples.
-
- Look in conf/samples for more realistic sample configurations.
- conf/samples/simple.conf - a simple, basic configuration
- conf/samples/deploy.conf - a simple configuration for deployment
-
- The configuration is based on a purely element-based XML. To make
- it easier to read, attributes can be used as syntactic sugar.
-
- The following are equivalent:
- 13 - canonical representation, but verbose
- - typical configuration
- - sometimes useful
-->
<!-- Security providers. Adding JSSE looks like:
-
-->
jdbc/etec
javax.sql.DataSource
/var/local/doc
GBK
<!--
-->
2
false
<!--
- Select an error page to display when the connection fails.
-
-
-->
true
150
<!--
- Ping to test if the web server is still up. You can uncomment this
- and point it to pages on the webserver that exercise your main
- logic (like database access). If the GET fails, it will restart
- the server. This will catch deadlocks, but not JDK freezes.
-
-
- http://localhost:8080/ping/ping.jsp
-
-->
true
<!--
- servlet configuration outside the is a default for all hosts.
-->
index.xtp, index.jsp, index.html
<!--
- The standalone server should uncomment for access logging.
- With another web server, like Apache, the web server will
- log this information.
-->
4096
30
true
true
<!--
- WEB-INF/sessions
-->
<!--
-
-->
<!--
- Known broken browsers. These should no longer be necessary, but
- you can uncomment them if they become a problem.
-
-
-
-
-
-->
请问这个错误怎么回事
[回复]
匿名reply on 2010-03-19 22:36:29:
看看!
adminreply on 2010-03-27 10:54:55:
Resin 暂时没有接触过 ,呵呵。