A few days ago, we set up the j2ee runtime environment in windows. Because the company's servers use linux, we have also set up the j2ee runtime environment in linux today. The following is a detailed diary of my test OK:
1. Install JDK (installed in the/usr/java directory)
1. Download: jdk-7-ea-bin-b26-linux-i586-24_apr_2008.bin
Address: http://jx.newhua.com/down/jdk-7-ea-bin-b26-linux-i586-24_apr_2008.zip
Decompress the zip format jdk-7-ea-bin-b26-linux-i586-24_apr_2008.bin in windows
Upload it to the/usr/java directory of the linux server.
2. Add executable permissions to the file
[Root @ localhost java] # chmod x jdk-7-ea-bin-b26-linux-i586-24_apr_2008.bin
3. Perform jdk-7-ea-bin-b26-linux-i586-24_apr_2008.bin
[Root @ localhost java] #./jdk-7-ea-bin-b26-linux-i586-24_apr_2008.bin
Automatic Installation and generation directory jdk1.7.0
4. Configure Environment Variables
There are three ways to configure environment variables: Modify the/etc/profile file, modify the. bashrc file under the user directory, and directly modify it under the shell) I modified the/etc/profile file:
[Root @ localhost java] # vi/etc/profile
After opening the file, press the I key and add:
JAVA_HOME =/usr/java/jdk1.7.0
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.: $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar
Export JAVA_HOME PATH CLASSPATH
Press esc
Enter: wq to save and exit.
Restart the server
6. Test the configuration Environment
Write a simple HelloWorld to test it.
[Root @ localhost java] # vi HelloWorld. java
File input:
Public class HelloWorld {
Public static void main (String args []) {
System. out. println ("Hello World in Linux !!");
}
}
: Wq save and exit
[Root @ localhost java] # javac HelloWorld. java
No error. Next:
[Root @ localhost java] # java HelloWorld
Shell output:
Exception in thread "main" java. lang. NoClassDefFoundError: HelloWorld/java
Caused by: java. lang. ClassNotFoundException: HelloWorld. java
At java.net. URLClassLoader $ 1.run( URLClassLoader. java: 220)
At java.net. URLClassLoader $ 1.run( URLClassLoader. java: 209)
At java. security. AccessController. doPrivileged (Native Method)
At java.net. URLClassLoader. findClass (URLClassLoader. java: 208)
At java. lang. ClassLoader. loadClass (ClassLoader. java: 325)
At sun. misc. Launcher $ AppClassLoader. loadClass (Launcher. java: 294)
At java. lang. ClassLoader. loadClass (ClassLoader. java: 270)
At java. lang. ClassLoader. loadClassInternal (ClassLoader. java: 338)
Error: cocould not find the main class.
Error: a jni error has occurred, please check your installation and try again
(What is the cause of the above problem, but it does not seem to affect the running of the following jsp. It should be counted as jdk installation successful .)
Ii. tomcat installation: (also installed in the/usr/java directory)
: Http://mirror.vmmatrix.net/apache/tomcat/tomcat-5/v5.0.28/bin/jakarta-tomcat-5.0.28.tar.gz
1. decompress the package to the/usr/java directory:
[Root @ localhost java] # tar-zxvf jakarta-tomcat-5.0.28.tar.gz
A new directory jakarta-tomcat-5.0.28 will appear under the/usr/java directory
2. Create a file link:
[Root @ localhost java] # ln-s jakarta-tomcat-5.0.28 tomcat
3. Configure CATALINA_HOME:
[Root @ localhost java] # vi/etc/profile
Add at the end of the file
CATALINA_HOME =/usr/java/tomcat
Export CATALINA_HOME
: Wq save and exit
4. start tomcat:
[Root @ localhost tomcat] # bin/startup. sh
Shell output:
Using CATALINA_BASE:/usr/java/tomcat
Using CATALINA_HOME:/usr/java/tomcat
Using CATALINA_TMPDIR:/usr/java/tomcat/temp
Using JAVA_HOME:/usr/java/jdk1.7.0
5. Enter http: // localhost: 8080 in the browser. The tomcat welcome page will appear. ^_^
6. Manage tomcat:
[Root @ localhost tomcat] # vi conf/tomcat-users.xml
In And Join:
7. restart the system:
Enter: http: // localhost: 8080/admin in the browser and you will be able to manage it.
Enter http: // localhost: 8080/manager/html to manage your project.
- Use System library files in Linux to reduce workload
- How to check whether a USB flash disk is connected in Linux
- Delete MySQL database data recovery in Linux EXT3