Install JDK and linuxjdk in Linux
CONTENTS (Chen kichao)
1 download
2 Installation
2.1 mount a USB flash drive
2.2 run the installation command
3 Configuration
4 Appendix 1: differences between rpmand tar.gz and installation and uninstallation
========================================================== ======================================
1 download
Official Website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Find the appropriate version, click Download, this example download is: jdk-7u71-linux-x64.rpm
2 Installation
2.1 mount a USB flash drive
Usb mobile devices are usually identified as sda1. If you do not know which one to be identified, you can use the command fdisk-l to query it. You can determine which one is your usb disk based on the detailed information described.
We can see that/dev/sdb1 is my USB flash drive.
1. mount the usb flash disk to the/mnt/usb directory. If the directory does not exist, run the command mkdir/mnt/usb to create it. mount the command mount/dev/sdb1/mnt/usb.
USB flash drive mounted!
2. unmount the USB flash drive
Command: umount/mnt/usb or/dev/sdb1. You can try either of them.
USB flash drive uninstalled!
2.2 run the installation command
1. Find the JDK to be installed in the mounted USB flash drive;
2. Execute the installation command according to the description in Appendix 1;
During installation, if the system has not installed the RPM (RedHat Packge Manager) Package Manager, the system will prompt that no rpm is installed for this project. You can run the following command to install apt-getinstall rpm:
Follow the prompts to install
Because the virtual machine is not configured to connect to the network, it is pending... Solution
Switch to tar.gz for Installation
Run the tar.gz compressed package installation command: tar zxvf/mnt/usb/software/Linux/jdk-7u71-linux-x64.tar.gz
After decompression, move to the/java folder. If java does not exist, create mkdir/java. You do not need to delete rm-rf/java.
Note:-r refers to recursion down, regardless of the number of levels of directories, which can be deleted together;-f refers to direct force deletion without any prompting;
3 Configuration
1. Set environment variables:
Use vi to open/etc/profile
Note: All operations in this document are performed by the root user. Therefore, the sudo command format is not required.
Add the following at the end of the file:
ExportJAVA_HOME =/java/jdk1.7.0 _ 71
Export CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib/tools. jar
Export PATH = $ PATH: $ JAVA_HOME/bin
2. Make the environment variable take effect:
Source/etc/profile
3. set to use JDK among all users:
After switching to another user, JDK is not installed because the user does not have the permission.
Configure General JDK for users --
Command: vi/etc/profile. d/java. sh
Enter the following content in the new java. sh:
JAVA_HOME =/java/jdk1.7.0 _ 71
CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib/tools. jar
PATH = $ PATH: $ JAVA_HOME/bin
ExportJAVA_HOME CLASSPATH PATH
Save and exit, and then grant java. sh the following permissions:
Chmod 755/etc/profile. d/java. sh
After the configuration is complete, run the following command to make the environment variable take effect.
Source/etc/profile
Note: Each user must execute this command during logon to make the changed environment variables take effect. Restarting the operating system is ineffective. You must execute this command.
4 Appendix 1: differences between rpmand tar.gz and installation and uninstallation
The binary distribution of Linux software refers to the release form of a compiled binary software package. Its advantage is that it is easy to install and use, and its disadvantage is that it lacks flexibility, if the software package is compiled for a specific hardware/operating system platform, it cannot be correctly executed on another platform or environment.
1. * binary software package in rpm format
Installation: rpm-ivh *. rpm
Uninstall: rpm-epackgename
Note: RPM (RedHat Packge Manager) is a software package Manager provided by RedHat. It can be used to install, upgrade, uninstall, verify, and query software packages in rpm format, it is easy to install, and files installed in multiple directories can be deleted during uninstallation. Therefore, it is recommended that you use rpm software packages as much as possible for beginners. In rpm parameters,-I is the installation,-v is the verification, and-h is the use of hashes to display the installation progress ,*. rpm is the file name of the software package (here *. rpm refers *. src. files other than rpm with the suffix "rpm"); parameter-e is the software package to be deleted, and packgename is the software package name, which is different from the file name of the software package, it is often a string in the file name that is located before the version number, for example, the apache-3.1.12-i386.rpm and the apache-devel-3.1.12-i386.rpm are the package file names, whose packages are apache and apache-devel, respectively. For more rpm parameters, see man rpm.
2. Binary packages in the form of * .tar.gz/*. tgz and *. bz2
Installation: tar zxvf * .tar.gz or tar yxvf *. bz2
Uninstall: manually delete
Note: The binary software package in the form of * .tar.gz/*. bz2 is packaged with the tar tool and compressed with gzip/bzip2. You can unpack the package directly during installation. For software that only has a single directory after decompression, run the "rm-rf Software Directory Name" command during uninstallation. If the files are scattered in multiple directories, you must manually delete them one by one (a little effort). To know which files are installed in the system during decompression, run the "tar ztvf * .tar.gz"/"tar ytvf *. bz2 "to get the list. The tar Parameter z is to call gzip for decompression, x is to unpack, v is to verify, f is to show the result, y is to call bzip2 for decompression, and t is to list the file list of the package. For more parameters, see man tar.
If you prefer graphic operations, you can use KDE's ArK compression file management tool in X-Window.
========================================================== ====
The source code distribution of Linux software refers to the release form of the source code of all programs of the software. You need to compile and install the executable binary code on your own. The advantage is that the configuration is flexible, some functions/modules can be removed or retained at will to adapt to a variety of hardware/operating system platforms and compiling environments. The disadvantage is that it is difficult and is generally not suitable for beginners.
1. * Source code package in the form of src. rpm
Install: rpm-rebuild *. src. rpm
Cd/usr/src/dist/RPMS
Rpm-ivh *. rpm
Uninstall: rpm-epackgename
Note: The rpm -- rebuild *. src. rpm command compiles the source code and generates a binary rpm package under/usr/src/dist/RPMS. then install the Binary Package. Packgename is described above.
2. Source Code packages in the form of * .tar.gz/*. tgz and *. bz2
Install: tar zxvf * .tar.gz or tar yxvf *. bz2 first
Then go to the decompressed directory:
./Configure Configuration
Make Compilation
Make install Installation
Uninstall: makeuninstall or manually delete
Note: It is recommended that you decompress the package and read the instruction file to learn about the installation requirements and modify the compilation configuration when necessary. The source code of some software packages can be uninstalled by using the make install command after compilation and installation. If this function is not provided, the software must be manually deleted. Because the software may install files in multiple directories of the system, it is often difficult to delete the files, you should configure them before compilation, specify the path to which the software will be installed :. /configure -- prefix = directory name. In this way, you can run the "rm-rf Software Directory Name" command to thoroughly uninstall the directory. Compared with other installation methods, it is the most difficult to compile and install by yourself. It is suitable for users who already have some experience in Linux. It is generally not recommended for beginners.
Appendix 1 from:
Http://www.pttc.yn.cninfo.net/dtsy/nettech/linux/2001927104108.htm