Because it is developed in the j2ee background, it is essential for every java programmer to build a j2ee environment on Linux. Therefore, this article mainly records the setup process of the j2ee environment, including the installation of jdk, tomcat, and eclipse (the installation of the mysql database will be recorded in the subsequent documents ).
I. jdk1.7 installation and environment setup
After CentOS6.4 is installed, jdk1.6 and jre-1.7.0-openjdk are installed by default. Here we choose to install our own jdk1.7
First go to the oracle official website to download jdk1.7, my CentOS is 64-bit, so select 64-bit download, (I downloaded the jdk-7u17-linux-x64.tar.gz)
You can download the corresponding jdk version based on your own version:
Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Because I have already made jdk1.7, tomcat, eclipse, and other software into an ISO file, therefore, you can directly mount the ISO file to CentOS (My ISO file is mounted to the/media/path, the previous article has clearly written CentOS (5) for Linux learning-a depressing mount command for me. Through the following command, we can view all the files in ISO:
[Root @ xiaoluo 2013033369132633] # ls-l total usage 400162-r --------. 1 xiaoluo 7831716 March 31 13:24 apache-tomcat-7.0.39.tar.gz-r --------. 1 xiaoluo 191737778 March 31 11:58 eclipse-SDK-4.2.2-linux-gtk-x86_64.tar.gz-r --------. 1 xiaoluo 6451189 March 31 11:56 httpd-2.4.4.tar.gz-r --------. 1 xiaoluo 96160926 March 31 12:34 jdk-7u17-linux-x64.tar.gz-r --------. 1 xiaoluo 24083795 March 31 12:43 mysql-5.0.41.tar.gz-r --------. 1 xiaoluo 83498652 March 31 13:17 MySQL-embedded-5.6.10-1.el6.x86_64.rpm
【Note:] Because we mount the ISO file to the/media path, it is equivalent to loading the virtual optical drive, and all the files in it are read-only, if you need to install the tool, you must copy the required files to other directories. Here, I choose to move all files to the/home path. The command is as follows:
[root@xiaoluo 20130331_132633]# cp apache-tomcat-7.0.39.tar.gz /home[root@xiaoluo 20130331_132633]# cp eclipse-SDK-4.2.2-linux-gtk-x86_64.tar.gz /home[root@xiaoluo 20130331_132633]# cp httpd-2.4.4.tar.gz /home[root@xiaoluo 20130331_132633]# cp jdk-7u17-linux-x64.tar.gz /home[root@xiaoluo 20130331_132633]# cp mysql-5.0.41.tar.gz /home[root@xiaoluo 20130331_132633]# cp MySQL-embedded-5.6.10-1.el6.x86_64.rpm /home
In this way, we have these files in the/home directory, and then we can install and decompress them.
Note:For files in the .tar.gz format, install and decompress files in linux using the tar-zxvf command.
For files in. bin format, install and decompress files using the./command in linux.
For executable files in linux, if we need to run it, it is also used./command
(Install and decompress files in. rpm and other formats, which will be recorded in future studies)
I am not very familiar with the decompression of the .tar.gz file and the meaning of the format. You can refer to this blog post for details:
Install and uninstall files in the .tar.gz format in Linux
For jdk-7u17-linux-x64.tar.gz, we use
[root@xiaoluo home]# tar -zxvf jdk-7u17-linux-x64.tar.gz
Decompress it. We can find that there is a jdk1.7.0 _ 17 folder under the/home path, which is the decompressed jdk folder.
Now that jdk has been installed and installed, We must configure environment variables for jdk in windows. In Linux, we also need to configure environment variables for jdk, so that jdk can run.
Jdk environment variable Configuration:
In Linux, the configuration information of the installation software is usually stored in the/etc/profile file. We can view the file through the command:
[Root @ xiaoluo home] # vi/etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in/etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. it's much better to create a custom. sh shell script in #/etc/profile. d/to make custom changes to your environment, as this # will prevent the need for merging in futur E updates. pathmunge () {case ": $ {PATH}:" in *: "$1": *); *) if ["$2" = "after"]; then PATH = $ PATH: $1 else PATH = $1: $ PATH fi esac} if [-x/usr/bin/id]; then if [-z "$ EUID"]; then # ksh workaround EUID = 'id-U' UID = 'id-ru 'fi USER = "'id-un'" LOGNAME = $ user mail = "/var/spool/ mail/$ USER "fi # Path manipulationif [" $ EUID "=" 0 "]; then pathmunge/sbin pathmunge/usr/local/sbinelse Pathmunge/usr/local/sbin after pathmunge/usr/sbin after pathmunge/sbin afterfiHOSTNAME = '/bin/hostname 2>/dev/null 'histsize = 1000if ["$ HISTCONTROL" = "ignorespace"]; then export HISTCONTROL = ignorebothelse export HISTCONTROL = ignoredupsfiexport path user logname mail hostname histsize histcontrol # By default, we want umask to get set. this sets it for login shell # Current threshold for system r Eserved uid/gids is 200 # You cocould check uidgid reservation validity in #/usr/share/doc/setup-*/uidgid fileif [$ UID-gt 199] & ["' id-gn '"=" 'id-un' "]; then umask 002 else umask 022 running or I in/etc/profile. d /*. sh; do if [-r "$ I"]; then if ["$ {-# * I }"! = "$-"]; Then. "$ I" else. "$ I">/dev/null 2> & 1 fi fidoneunset iunset-f pathmungeExport JAVA_HOME =/home/jdk1.7.0 _ 17 export PATH = $ PATH:/home/jdk1.7.0 _ 17/binexport CLASSPATH =. :/home/jdk1.7.0 _ 17/lib/dt. jar:/home/jdk1.7.0 _ 17/lib/tools. jar //. the following is: (colon), which is used for separation in linux: to indicate export JAVA_HOME path classpath // modify the profile file. Add our environment variable to the end, which is similar to windows environment variable configuration.
Save and exit. Execute:
# Source/etc/profile //This command is used to make the configuration take effect immediately. Sometimes, even if you have typed this command, the configuration does not take effect, so you need to configure it again.
Note:Now we can check the jdk version to see if it is the jdk 1.7 we just installed and enter java-version. We are sorry for the result. We have installed the jdk for CentOS before, this indicates that our configuration has not taken effect. Therefore, to replace the built-in jdk with your own jdk, you need to make the following settings:
First install java alternative -- jdk # update-alternatives -- install/usr/bin/java/home/jdk1.7.0 _ 17/bin/java 60 // here/usr/bin/java representative the built-in jdk/home/jdk1.7.0 _ 17/bin/java indicates the jdk we just installed.
Then configure JDK: # update-alternatives -- config java
The following prompt appears:
A total of four programs provide "java ".
Select command
-----------------------------------------------
A total of four programs provide "java ". Select command ------------------------------------------- * 1/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java 2/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java 3/usr/lib/jvm/jre-1.5.0-gcj/ bin/java + 4/home/jdk1.7.0 _ 17/bin/java
In this case, we select/home/jdk1.7.0 _ 17/bin/java to move the [+] cursor to 4, or directly enter the number 4, and press enter to confirm, then jdk is configured, replace jdk with jdk 1.7 installed by yourself. Enter java-version again. We can see that:
[root@xiaoluo home]# java -versionjava version "1.7.0_17"Java(TM) SE Runtime Environment (build 1.7.0_17-b02)Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Similarly, we can enter the java and javac commands to verify that the jdk environment has been configured !!!
Ii. Installation and environment setup of Tomcat 7
The following is the installation of Tomcat 7, because Tomcat 7 is also a file in .tar.gz format
[root@xiaoluo home]# tar -zxvf apache-tomcat-7.0.39.tar.gz
After decompression, we can also find that there is an apache-tomcat-7.0.39 folder in the/home path, which is the decompressed tomcat7, we also need to configure tomcat environment variables in/etc/profile:
[Root @ xiaoluo home] # vi/etc/profile
Modify the last few lines of code in the configuration file:
Unset I
Unset-f pathmunge
Export JAVA_HOME =/home/jdk1.7.0 _ 17
Export PATH = $ PATH:/home/jdk1.7.0 _ 17/bin
Export CLASSPATH =.:/home/jdk1.7.0 _ 17/lib/dt. jar:/home/jdk1.7.0 _ 17/lib/tools. jar
Export CATALINA_HOME =/home/apache-tomcat-7.0.39
Export JAVA_HOME path classpath CATALINA_HOME
In this case, go to the bin directory in apache-tomcat-7.0.39 and run the startup. sh file to start the server:
[Root @ xiaoluo home] # cd/home/apache-tomcat-7.0.39/bin/[root @ xiaoluo bin] #./Startup. sh //. /The command is to run the command. If the file is an executable file, it passes. /, if the file is. bin format, also use. /command to install and decompress the file
Now we open the Firefox browser that comes with CentOS and enter http: // localhost: 8080. Then we can see the familiar cat !!!
To disable the server, run the following command:
[root@xiaoluo bin]# ./shutdown.sh
In this way, our tomcat has been installed !!!!
Iii. Installation of eclipse
Although there is a powerful editor in Linux-vi editor that can be used to write any code, but the efficiency is too low, it is necessary to install an IDE tool, so we still need to install an eclipse on Linux.
The Linux kernel of the downloaded eclipseis .tar.gz, so the installation method is the same as above:
[root@xiaoluo home]# tar -zxvf eclipse-SDK-4.2.2-linux-gtk-x86_64.tar.gz
After the installation is complete, there is an additional eclipse folder under/home. Let's go to it and run the following command to start eclipse:
[Root @ xiaoluo eclipse] #./eclipse
Note:If it is in development mode, you must switch to the graphical interface before eclipse can run, because eclipse itself is a graphical interface. If it is run on a GUI terminal, you can run it directly using commands.
Now we can see the eclipse interface we are familiar !!!!!
Of course, all the other software required for j2ee development is described in detail, including MyEclipse for web development, you can install MyEclipse on Linux. The installation process is the same as that of other software such as eclipse ), mysql database (this will be recorded separately in subsequent articles !)