--------------------------------------------------------------------
Author:jiangxin
Email:[email protected]
Blog:http://blog.csdn.net/jiangxinnju
--------------------------------------------------------------------
Assuming that you have to use Java to develop your application in Linux, you will feel that the installation of software such as JDK and Eclipse in Linux is very complex, so I wrote a script specifically for installing/uninstalling the JDK and Eclipse on my own initiative under Linux. Implementation of a key to the loading and unloading, no matter what additional files generated. You can try it.
File packages, etc.:
Http://pan.baidu.com/s/1sjArVM9
The script can proactively identify whether the system is 32-bit or 64-bit. and choose the JDK and Eclipse version number on your own initiative.
Test environment:
Linux release number: Ubuntu 14.04
JDK Version number:
jdk-7u60-linux-i586 (32-bit)
Jdk-7u60-linux-x64 (64-bit)
Eclipse Version Number:
ECLIPSE-JAVA-LUNA-R-LINUX-GTK (32-bit)
ECLIPSE-JAVA-LUNA-R-LINUX-GTK-X86_64 (64-bit)
When using, make sure that the following files exist in this directory:
├──eclipse-java-luna-r-linux-gtk.tar.gz
├──eclipse-java-luna-r-linux-gtk-x86_64.tar.gz
├──install.sh
├──jdk-7u60-linux-i586.tar.gz
├──jdk-7u60-linux-x64.tar.gz
├──readme
└──uninstall.sh
You can try to change the script to make it more suitable for your own functions. You are welcome to make changes.
Some Linux systems will bring their own openjava to see if Java/javac and other commands are valid before installing.
Installation script:
#!/bin/bashecho "Creating/usr/lib/jvm/folder" sudo mkdir/usr/lib/jvm/echo "folder/usr/lib/jvm/created successfully" echo "is installing JDK and Eclipse" Os_ version= ' uname-a ' echo $os _versionarchitecture= "$os _version" | Grep-q "$architecture" if [$? -eq 0]thenecho "You are using a 64-bit operating system. Choose 64-bit JDK and Eclipse "sudo tar-zxvf jdk-7u60-linux-x64.tar.gz-c/usr/lib/jvm/sudo chown-r jiangxin:jiangxin/usr/lib/for you Jvm/jdk1.7.0_60sudo tar-zxvf eclipse-java-luna-r-linux-gtk-x86_64.tar.gz-c/usr/bin/sudo chown-r jiangxin:jiangxin/ Usr/bin/eclipsesudo ln-s/usr/bin/eclipse/eclipse ~/desktop/eclipseelseecho "You are using a 32-bit operating system to choose 32-bit JDK and Eclipse" sudo TAR-ZXVF jdk-7u60-linux-i586.tar.gz-c/usr/lib/jvm/sudo chown-r Jiangxin:jiangxin/usr/lib/jvm/jdk1.7.0_60sudo Tar- ZXVF eclipse-java-luna-r-linux-gtk.tar.gz-c/usr/bin/sudo chown-r jiangxin:jiangxin/usr/bin/eclipsesudo ln-s/usr/ Bin/eclipse/eclipse ~/desktop/eclipsefiecho "Install JDK and Eclipse success" echo "config environment variable" # Touch Environment # echo "path=\" $PATH:/ Usr/lib/jvm/jdk1.7.0_60/bin\ "" >> environment# echo "java_home=/usr/lib/jvm/jdk1.7.0_60" >> environment# echo "Classpath=.:%java_home%/lib/dt.jar:%java_home%/lib/tools.jar" >> environment# sudo mv/etc/environment/ etc/environment.backup.java# suDo MV environment/etc# source/etc/environmentmv ~/.BASHRC ~/.bashrc.backup.javacat ~/.bashrc.backup.java >> ~/. Bashrcecho "Path=\" $PATH:/usr/lib/jvm/jdk1.7.0_60/bin\ "" >> ~/.bashrcecho "java_home=/usr/lib/jvm/jdk1.7.0_ ">> ~/.bashrcecho" Classpath=.:%java_home%/lib/dt.jar:%java_home%/lib/tools.jar ">> ~/.bashrcsource ~ /.bashrcecho "Configuration Environment succeeded" # Assume that there are multiple Java version numbers that need to be configured below (including OPENJDK) echo "Set default JDK" sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_60/bin/java 300sudo update-alternatives--install/usr/bin/javac javac/usr/lib/jvm/ Jdk1.7.0_60/bin/javac 300sudo update-alternatives--config java# echo "Set default JDK Success" echo "Test successfully installed" Java-versionecho "successfully installed "
Uninstall script:
echo "Deleting related files" sudo rm-rf/usr/lib/jvm/sudo rm-rf/usr/bin/eclipse/sudo rm-rf ~/desktop/eclipsewaitecho "Delete related files Success" echo "Recover config file" # sudo rm-f/etc/environment# sudo mv/etc/environment.backup.java/etc/environmentsudo rm/usr/bin/java/usr/bi N/javacsudo RM/ETC/ALTERNATIVES/JAVA/ETC/ALTERNATIVES/JAVACMV ~/.bashrc.backup.java ~/.bashrcecho "restore profile succeeded"
Jdk/eclipse One-click installation script in the Linux environment