Linux operating system JDK and Tomcat installation notes -- linux configuration java environment details

Source: Internet
Author: User
~~~~~~~~~~~~~~~ The following describes the JDK installation process ~~~~~~~~~~~ From: www.linuxso.com ~~~~~~~~~~~~~ I. Unzip the installation jdk into the jdk official website download: JDK: http: download. java. netjdk6 in the shell terminal to enter the directory of the jdk-6u14-linux-i586.bin file, through the chmod + xjdk-6u7-linux

~~~~~~~~~~~~~~~ The following describes the JDK installation process ~~~~~~~~~~~ From: www.linuxso.com ~~~~~~~~~~~~~

I.ExtractInstall jdk 

Go to jdk official website download: JDK: http://download.java.net/jdk6/
Go to the jdk-6u14-linux-i586.bin file directory under the shell terminalChmod+ X jdk-6u7-linux-i586.binCommandGive it executable permissions
Run the command./jdk-6u14-linux-i586.bin to install a protocol, followed by a carriage return, when asked whether to agree, enter yes, press Enter.

A jdk1.6.0 _ 14 directory will be generated in the current directory. You can copy it to any directory.

2. environment variables to be configured 
1. PATH environment variable. The function is to specify the command search PATH. When you execute a command under shell, it searches for the PATH specified by the PATH variable to see if the corresponding command program can be found. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/java/javadoc waiting, after setting the PATH variable, You can execute tools such as javac and java in any directory.
2. CLASSPATH environment variable. The function is to specify the Class search path and use the classes that have already been compiled. The premise is that you can find them, and JVM searches for classes through CLASSPTH. We need to set dt. jar and too in the lib subdirectory under the jdk installation directoryLs. Jar is set to CLASSPATH. Of course, the current directory "." must also be added to this variable.
3. JAVA_HOME environment variable. It points To the jdk installation directory, Eclipse/NetBeans/McAt and other software find and use the installed jdk by searching the JAVA_HOME variable.

3. Three Methods for configuring Environment Variables1. Modify/etc/proFileFile
This method is recommended if your computer is used only for development, because all users' shells have the right to use these environment variables, which may bring security issues to the system.
& MiDdOt; open/etc/profile in a text editor


Vi/etc/profile

Modify the file as follows. The red part is the part to be modified.

#/Etc/profile
# System wIdE environment and startup programs, for loginSetUp
# FuNcTions andAliasEs 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
UnsetPathmunge
# 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'
History Size = 1000

If [-z "$ INPUTRC"-! -F "$ HOME/. inpuTrC "]; then
INPUTRC =/etc/inputrc
Fi

JAVA_HOME =/usr/java/jdk1.6.0 _ 07

PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin

CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ CLASSPATH

ExPort PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRCJAVA_HOME CLASSPATH

For I in/etc/profile. d/*. sh; do
If [-r "$ I"]; then
. $ I
Fi

Done

Unset I

ExportG_BROKEN_FILENAMES = true

· Log on again
· Annotation
A. Change/usr/share/jdk1.6.0 _ 14 to your jdk installation directory.
B. Use the colon ":" To separate paths in linux
C. $ PATH/$ CLASSPATH/$ JAVA_HOME is used to reference the value of the original environment variable.
When setting environment variables, pay special attention not to overwrite the original values. This is
Common errors.
D. The current directory "." In CLASSPATH cannot be lost. It is also a common error to discard the current directory.
E. export exports the three variables as global variables.
F. Case sensitivity is required.

2. Modify the. bash_profile File 

This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify. you can use the bash_profile file.
· Open the. bash_profile file in the user directory in a text editor
· Add the following content to the end of the. bash_profile file:

Export JAVA_HOME =/usr/share/jdk1.6.0 _ 14
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

· Log on again

3. directly set variables in shell
I am not in favor of using this method. If you change the shell, your settings will be invalid. Therefore, this method is only for temporary use and will be re-set later, which is troublesome.
Run the following command on the shell terminal:
Export JAVA_HOME =/usr/share/jdk1.6.0 _ 14
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

4. Test jdk 
1. Create a Test. java file in the text editor, enter the following code and save it:
Public class test {
PublicStatIc void main (String args []) {
System. out. printLn("A new jdk test! ");
}
}
2. Compile: Execute the command javac Test. java on the shell terminal.
3. Run: run the java Test command on the shell terminal.
When "A new jdk test!" appears in shell !" Jdk runs normally.

5. Uninstall jdk 
· Find the _ uninst subdirectory of the jdk installation directory.
· Run the command./uninstall. sh on the shell terminal to uninstall jdk.

~~~~~~~~~~~~~ TomCatInstallation Process ~~~~~~~ From: www.linuxso.com ~~~~~~~~~~~~~~~~~~~~~~

I. Download and unzip TOMCAT

Tomcat6 Official Website: http://tomcat.apache.org/download-60.cgi

 

In fact, Tomcat does not need to be installed. You only need to execute the following command to decompress the package.

# Tar xvzf apache-tomcat-6.0.18.tar.gz

After the execution, a folder is generated in the directory of the apache-tomcat-6.0.18.tar.gz file. You can move it to another directory.

 

Run/bin/startup. sh in the "cmda" directory to start the Tomcat service.

 

II:Test the installation result in a browser

After JDK and Tomcat are installed, enter the IP address and port number (default port 8080) in the local browser to test the installation interface.

Note: If you want to modify the Tomcat port (for example, change port 8080 to port 80), use vi to open/conf/server. xml in the Tomcat directory.

Modify

Col= "HTTP/1.1" connectionTimeout = "20000" r EdIrectPort = "8443"/>

Is

After modifying this configuration file, restart the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.