linux 下JDK的卸载与安装
###################################################JDK卸载
[[email protected]]#java-version//检查JDK版本命令
javaversion"1.4.2"
gij(GNUlibgcj)version4.1.220080704(RedHat4.1.2-46)
[[email protected]]#rpm-qa|grepjdk//检查命令1
[[email protected]]#rpm-qa|grepgcj//检查命令2
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
libgcj-4.1.2-46.el5
java-1.4.2-gcj-compat-src-1.4.2.0-40jpp.115
libgcj-devel-4.1.2-46.el5
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115
libgcj-src-4.1.2-46.el5
[[email protected]]#yum-yremovejava-1.4.2-gcj-compat-1.4.2.0-40jpp.115Loadedplugins:rhnplugin,security//卸载命令
ThissystemisnotregisteredwithRHN.
RHNsupportwillbedisabled.
SettingupRemoveProcess
ResolvingDependencies
-->Runningtransactioncheck
--->Packagejava-1.4.2-gcj-compat.i3860:1.4.2.0-40jpp.115settobeerased
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-codec
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-codec
-->ProcessingDependency:java-gcj-compatforpackage:antlr
-->ProcessingDependency:java-gcj-compatforpackage:antlr
-->ProcessingDependency:java-gcj-compatforpackage:junit
-->ProcessingDependency:java-gcj-compatforpackage:junit
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-logging
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-logging
-->ProcessingDependency:java-gcj-compat>=1.0.31forpackage:tomcat5-jsp-2.0-api
-->ProcessingDependency:java-gcj-compat>=1.0.31forpackage:tomcat5-jsp-2.0-api
-->ProcessingDependency:java-gcj-compat>=1.0.64forpackage:gjdoc
-->ProcessingDependency:java-gcj-compat>=1.0.64forpackage:gjdoc
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-httpclient
-->ProcessingDependency:java-gcj-compatforpackage:jakarta-commons-httpclient
-->ProcessingDependency:java-gcj-compat>=1.0.31forpackage:tomcat5-servlet-2.4-api
-->ProcessingDependency:java-gcj-compat>=1.0.31forpackage:tomcat5-servlet-2.4-api
-->ProcessingDependency:java-gcj-compatforpackage:bsf
-->ProcessingDependency:java-gcj-compatforpackage:bsf
-->ProcessingDependency:java-gcj-compatforpackage:xalan-j2
-->ProcessingDependency:java-gcj-compatforpackage:xalan-j2
-->ProcessingDependency:java-gcj-compatforpackage:xmlrpc
-->ProcessingDependency:java-gcj-compatforpackage:xmlrpc
-->ProcessingDependency:java-gcj-compatforpackage:bsh
-->ProcessingDependency:java-gcj-compatforpackage:bsh
-->ProcessingDependency:jaxp_parser_implforpackage:xalan-j2
-->ProcessingDependency:java-1.4.2-gcj-compat=1.4.2.0-40jpp.115forpackage:java-1.4.2-gcj-compat-src
-->ProcessingDependency:java-1.4.2-gcj-compat=1.4.2.0-40jpp.115forpackage:java-1.4.2-gcj-compat-devel
-->Runningtransactioncheck
--->Packageantlr.i3860:2.7.6-4jpp.2settobeerased
--->Packagebsf.i3860:2.3.0-11jpp.1settobeerased
--->Packagebsh.i3860:1.3.0-9jpp.1settobeerased
--->Packagegjdoc.i3860:0.7.7-12.el5settobeerased
--->Packagejakarta-commons-codec.i3860:1.3-7jpp.2settobeerased
--->Packagejakarta-commons-httpclient.i3861:3.0-7jpp.1settobeerased
--->Packagejakarta-commons-logging.i3860:1.0.4-6jpp.1settobeerased
--->Packagejava-1.4.2-gcj-compat-devel.i3860:1.4.2.0-40jpp.115settobeerased
--->Packagejava-1.4.2-gcj-compat-src.i3860:1.4.2.0-40jpp.115settobeerased
--->Packagejunit.i3860:3.8.2-3jpp.1settobeerased
--->Packagetomcat5-jsp-2.0-api.i3860:5.5.23-0jpp.7.el5_3.2settobeerased
--->Packagetomcat5-servlet-2.4-api.i3860:5.5.23-0jpp.7.el5_3.2settobeerased
--->Packagexalan-j2.i3860:2.7.0-6jpp.1settobeerased
--->Packagexmlrpc.i3860:2.0.1-3jpp.1settobeerased
-->ProcessingDependency:/usr/bin/rebuild-gcj-dbforpackage:eclipse-ecj
-->ProcessingDependency:/usr/bin/rebuild-gcj-dbforpackage:eclipse-ecj
-->RestartingDependencyResolutionwithnewchanges.
-->Runningtransactioncheck
--->Packageeclipse-ecj.i3861:3.2.1-19.el5settobeerased
-->FinishedDependencyResolution
DependenciesResolved
===============================================================================================
PackageArchVersionRepositorySize
===============================================================================================
Removing:
java-1.4.2-gcj-compati3861.4.2.0-40jpp.115installed441
Removingfordependencies:
antlri3862.7.6-4jpp.2installed2.5M
bsfi3862.3.0-11jpp.1installed812k
bshi3861.3.0-9jpp.1installed1.2M
eclipse-ecji3861:3.2.1-19.el5installed18M
gjdoci3860.7.7-12.el5installed1.7M
jakarta-commons-codeci3861.3-7jpp.2installed207k
jakarta-commons-httpclienti3861:3.0-7jpp.1installed1.3M
jakarta-commons-loggingi3861.0.4-6jpp.1installed233k
java-1.4.2-gcj-compat-develi3861.4.2.0-40jpp.115installed81k
java-1.4.2-gcj-compat-srci3861.4.2.0-40jpp.115installed0.0
juniti3863.8.2-3jpp.1installed602k
tomcat5-jsp-2.0-apii3865.5.23-0jpp.7.el5_3.2installed163k
tomcat5-servlet-2.4-apii3865.5.23-0jpp.7.el5_3.2installed250k
xalan-j2i3862.7.0-6jpp.1installed5.1M
xmlrpci3862.0.1-3jpp.1installed864k
TransactionSummary
===============================================================================================
Install0Package(s)
Update0Package(s)
Remove16Package(s)
DownloadingPackages:
Runningrpm_check_debug
RunningTransactionTest
FinishedTransactionTest
TransactionTestSucceeded
RunningTransaction
Erasing:java-1.4.2-gcj-compat-devel1/16
Erasing:bsf2/16
Erasing:antlr3/16
Erasing:tomcat5-servlet-2.4-api4/16
Erasing:jakarta-commons-codec5/16
Erasing:java-1.4.2-gcj-compat-src6/16
Erasing:jakarta-commons-logging7/16
Erasing:junit8/16
Erasing:tomcat5-jsp-2.0-api9/16
Erasing:xmlrpc10/16
Erasing:java-1.4.2-gcj-compat11/16
Erasing:xalan-j212/16
Erasing:jakarta-commons-httpclient13/16
Erasing:bsh14/16
Erasing:gjdoc15/16
Erasing:eclipse-ecj16/16
Removed:
java-1.4.2-gcj-compat.i3860:1.4.2.0-40jpp.115
DependencyRemoved:
antlr.i3860:2.7.6-4jpp.2
bsf.i3860:2.3.0-11jpp.1
bsh.i3860:1.3.0-9jpp.1
eclipse-ecj.i3861:3.2.1-19.el5
gjdoc.i3860:0.7.7-12.el5
jakarta-commons-codec.i3860:1.3-7jpp.2
jakarta-commons-httpclient.i3861:3.0-7jpp.1
jakarta-commons-logging.i3860:1.0.4-6jpp.1
java-1.4.2-gcj-compat-devel.i3860:1.4.2.0-40jpp.115
java-1.4.2-gcj-compat-src.i3860:1.4.2.0-40jpp.115
junit.i3860:3.8.2-3jpp.1
tomcat5-jsp-2.0-api.i3860:5.5.23-0jpp.7.el5_3.2
tomcat5-servlet-2.4-api.i3860:5.5.23-0jpp.7.el5_3.2
xalan-j2.i3860:2.7.0-6jpp.1
xmlrpc.i3860:2.0.1-3jpp.1
Complete!
[[email protected]]#java-version//再次检查JDK版本,卸载成功
-bash:/usr/bin/java:没有那个文件或目录
###################################################JDK安装
安装文件:用的安装包是jdk-6u22-linux-i586.bin,没有使用RedHat平台通用的rpm包。
首先,通过ftp将jdk-6u22-linux-i586.bin上传到/home/software下。
然后,要给jdk-6u11-linux-i586.bin分配权限,这里要给它可执行的权限,输入:chmod+xjdk-6u11-linux-i586.bin,这里参数x即使执行权限。
[[email protected]/]#cdhome/software//进入安装包所在的目录
[[email protected]]#ls
jdk-6u22-linux-i586.bin
[[email protected]]#chmod+xjdk-6u22-linux-i586.bin//赋予可执行的权限
[[email protected]]#./jdk-6u22-linux-i586.bin//开始解包
.........................省略
Creatingjdk1.6.0_22/jre/lib/deploy.jar
Java(TM)SEDevelopmentKit6successfullyinstalled.
ProductRegistrationisFREEandincludesmanybenefits:
*Notificationofnewversions,patches,andupdates
*SpecialoffersonSunproducts,servicesandtraining
*Accesstoearlyreleasesanddocumentation
Productandsystemdatawillbecollected.Ifyourconfiguration
supportsabrowser,theSunProductRegistrationformfor
theJDKwillbepresented.Ifyoudonotregister,noneof
thisinformationwillbesaved.Youmayalsoregisteryour
JDKlaterbyopeningtheregister.htmlfile(locatedin
theJDKinstallationdirectory)inabrowser.
FormoreinformationonwhatdataRegistrationcollectsand
howitismanagedandused,see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
PressEntertocontinue.....
Done.
[[email protected]]#ls//查看结包后的目录
jdk1.6.0_22jdk-6u22-linux-i586.bin
[[email protected]]#cdjdk1.6.0_22//进入解压包
[[email protected]_22]#ls//查看解压包内的内容
binincludeREADME.htmlregister_ja.htmlTHIRDPARTYLICENSEREADME.txt
COPYRIGHTjreREADME_ja.htmlregister_zh_CN.html
dblibREADME_zh_CN.htmlsample
demomanregister.htmlsrc.zip
[[email protected]]#mvjdk1.6.0_22/usr/local//通常将jdk1.6.0_22放在/usr/local目录下,所以先执行“移动”
[[email protected]]#cd/usr/local//进入/usr/local目录
[[email protected]]#ls//查看目录内容
binetcgamesincludejdk1.6.0_22liblibexecsbinsharesrc
###################################################JDK设置环境变量
设置环境变量有两种方法:
一是通过export设置临时生效,重启后设置会丢失。
二是将设置写入/etc/profile文件中,可以一直生效。所以我们采用此方法。
[[email protected]/]#vi/etc/profile//打开/etc/profile文件
[[email protected]/]#vi/etc/profile
#/etc/profile
#Systemwideenvironmentandstartupprograms,forloginsetup
#Functionsandaliasesgoin/etc/bashrc
pathmunge(){
if!echo$PATH|/bin/egrep-q"(^|:)$1($|:)";then
if["$2"="after"];then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
#kshworkaround
if[-z"$EUID"-a-x/usr/bin/id];then
EUID=`id-u`
UID=`id-ru`
fi
#Pathmanipulation
if["$EUID"="0"];then
pathmunge/sbin
pathmunge/usr/sbin
pathmunge/usr/local/sbin
fi
#Nocorefilesbydefault
ulimit-S-c0>/dev/null2>&1
if[-x/usr/bin/id];then
USER="`id-un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if[-z"$INPUTRC"-a!-f"$HOME/.inputrc"];then
INPUTRC=/etc/inputrc
fi
#JDK环境变量设置
exportJAVA_HOME=/usr/local/jdk1.6.0_22
exportPATH=$PATH:$JAVA_HOME/bin
exportCLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/rt.jar
pathmunge/usr/local/jdk1.6.0_22/bin:/usr/local/jdk1.6.0_22/jre/bin
exportPATHUSERLOGNAMEMAILHOSTNAMEHISTSIZEINPUTRC
foriin/etc/profile.d/*.sh;do
if[-r"$i"];then
if["$PS1"];then
.$i
else
.$i>/dev/null2>&1
fi
fi
done
unseti
unsetpathmunge
"/etc/profile"58L,1029C
[[email protected]/]#source/etc/profile//让配置生效
[[email protected]/]#java-version//检查JDK版本(新)
javaversion"1.6.0_22"
Java(TM)SERuntimeEnvironment(build1.6.0_22-b04)
JavaHotSpot(TM)ClientVM(build17.1-b03,mixedmode,sharing)