找回密码
 注册
搜索
热搜: java php web
查看: 219|回复: 0

[Java] 在Linux下安装JDK1.6.doc

[复制链接]
发表于 2010-1-4 13:22:57 | 显示全部楼层 |阅读模式
Linux下安装JDK1.6并且运行java程序和java项目例子
软件:jdk-6u13-linux-i586-rpm.bin
启动Linux系统,创建放软件的目录/usr/local/heshuzhen
[root@localhost ~]# mkdir -p /usr/local/heshuzhen
jdk-6u13-linux-i586-rpm.bin放到Linux下的/usr/local/heshuzhen目录下,
运行软件jdk-6u13-linux-i586-rpm.bin
[root@localhost ~]# cd /usr/local/heshuzhen/
[root@localhost heshuzhen]#chmod 777 jdk-6u13-linux-i586-rpm.bin
[root@localhost
heshuzhen]#./ jdk-6u13-linux-i586-rpm.bin
如出现停顿按空格
如出现下列提示
Do you agree to the above license terms? [yes or no]
输入yes
[root@localhost heshuzhen]# rpm -Uvh jdk-6u13-linux-i586.rpm
[root@localhost heshuzhen]# vi /etc/profile(以下是该文件修成了的地方)
Profile文件中的内容如下:其中红色的部分是新添加的配置
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {

if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then


if [ "$2" = "after" ] ; then


PATH=$PATH:$1


else


PATH=$1:$PATH


fi


fi

}

# Path manipulation
if [ `id -u` = 0 ]; then

pathmunge /sbin

pathmunge /usr/sbin


pathmunge /usr/local/sbin

fi

pathmunge /usr/X11R6/bin after

1,1
顶端
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then

INPUTRC=/etc/inputrc

fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do

if [ -r "$i" ]; then


. $i


fi

done

unset i
unset pathmunge
#这里要注意,你要根据自己的安装的路径来写
JAVA_HOME=/usr/java/jdk1.6.0_13
CLASSPATH=$JAVA_HOME/lib/tools.jar/$JAVA_HOME/jre/lib/rt.jarPATH=$PATH/$HOME/BIN/$JAVA_HOME/BIN/$JAVA_HOME/jre/bin
export JAVA_HOME CLASSPATH
PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

1、测试jdk是否安装成功
[root@localhost FtpClient]# java -version
java version "1.4.2"
gcj (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2、可以写一个简单的java程序进行测试:
[root@localhost heshuzhen]# vi A.java

类名:A.java
public class A
{

public static void main(String args[])


{



System.out.println("Hello World
");

}

}

编译程序:
[root@localhost heshuzhen]# javac A.java

运行程序:
[root@localhost heshuzhen]# java A

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|软晨网(RuanChen.com)

GMT+8, 2024-11-23 08:36

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表