Install and configure Tomcat and use in NetBeans

Source: Internet
Author: User
Tags server port tomcat server apache tomcat netbeans

Tomcat is not much different from IIS in nature, and they all support Web programs as Web servers, except that IIS is a Web server for. NET and Tomcat is a Web server for Java. and the so-called Web server we might as well consider it as a web container, where we do a good job will be published to others web pages and related files. We publish the IP address of our computer (including the port number) and the address of the Web container on our computer so that someone else can find our computer via IP, and then find the box with the Web page in the Web container address and request the page in the box. How the Web server works is easy to understand, but the installation of a Web server is always a headache for many people, so let's go into the details of installing a Tomcat server and using that server in the NetBeans IDE.

(1) Before installing the Tomcat server, you need to install the JDK (Java Development Kit) and the JDK installation see the following information: http://blog.csdn.net/mazhaojuan/article/details/ 7468639, in this article we will focus on the installation and configuration of Tomcat.

(2) Download good tomcat Double-click Setup (you can choose the default or you can choose your own installation path) for installation. The following points need to be noted during installation:

I. Steps such as allowing you to select a path for JDK support during the installation process, if the JDK is installed correctly, the installer is automatically found, and you do not need to change the direct click "Next".

Ii. the option to select HTTP ports appears during the installation process. The default is 8080, but this step if you choose the default may be in the future run due to port conflicts in the program will not release the normal, here we will install by default, the specific problem description is described below.

(3) Configure environment variables. Click computer → properties → advanced system settings → environment variables. Here we mainly configure four environment variables:

I. Tomcat_home. This variable points to the installation path for Tomcat, which has folders such as Bin,conf,lib,logs,temp,webapps,work. Click "New" under "System Variables", the variable name is: tomcat_home, the variable value is Tomcat installation path, if Tomcat is installed in E:\Tomcat 6 directory, then the variable value is E:\Tomcat 6.

Ii. Catalina_home. The environment variable is set in the same way as Tomcat_home, first click "New" under the system variable, the variable name is Tomcat_home, and the variable value is Tomcat's installation path E:\Tomcat 6.

Iii. Path. Locate the path variable in the system variable, add%talina_home%\bin after the value of the variable, and note that there should be a semicolon between the newly added value and the original value.

Iv. CLASSPATH. Find the CLASSPATH variable in the system variable, click on the "Edit" button, add%talina_home%\bin\servlet-api.jar after the value of the variable, and note that there should be a semicolon between the newly added value and the original value.

V. Since we are using the installation version of Tomcat, the Tomcat service item has been completed during installation, and if you are using a version-free tomcat, you will need to manually install the Tomcat service in a DOS environment with the following steps:

1. Win + R into the DOS environment.

2. Use DOS command to enter into Tomcat's decompression directory.

3. Run the Service.bat install command to install the Tomcat service items.

4. Check to see if the Tomcat Service entry was successfully installed. The win key calls out "menu" and then enters the "service" in the bottom search bar, finds the corresponding program and clicks on it, and if you can find Apache Tomcat 7 in the Service item list, the service item installation is successful.

(4) Open the service. Locate the Tomcat7w.exe file under the Bin folder under the installation path, double-click the file, and then click the "Start" button to open the service.

At this point, the Tomcat installation configuration is complete, and here's how to use the Tomcat server in a NetBeans environment.


(1) Install the NetBeans IDE. The installation process is easy, I believe you have no difficulty, the difficulty is how to use the Tomcat server in the NetBeans environment.

(2) Add server. Click "Tools"--"server"--"Add Server", in the "Server Location" box, select the installation path for the tomcat we installed previously (there are bin,conf,lib,logs,temp,webapps,work folders under this path), enter the username and password , click Next (or you can directly point to finish), the contents of the check box may not be selected, click Finish

(3) Problems you may encounter when you run your project:

I. Tomcat startup error: Port 8080 is occupied. This error occurs because of the use of the default port setting that was mentioned during the installation above. Since port 8080 is the default port for the Web server, if the IIS server is turned on on your computer, it is likely that the port has already been occupied by the IIS server (or, of course, by another program, which is the most likely to be occupied by IIS), and which program occupies We can find the PID of the port by Net–ano this DOS command, then click "View" in Task Manager-"SELECT column"-"Check pid", click OK, click "Process" tab, find the corresponding program according to PID and terminate this program. This approach is less insurance and more troublesome, and the solution we use is to change Tomcat's port number to fundamentally solve this problem: after clicking "Tools"-"server" we can see the server we added before, in the "Server port" Item we will change the port number to 8081, This basically solves the problem that the port is occupied.

Ii. after changing the port number, run the program again, indicating that "Tomcat cannot access the URL through an external browser, check the browser configuration" error, although there are errors here, we can again verify that the port number is occupied by the problem has been resolved. How should this problem be solved? In fact, the solution is very simple, the problem is that we do not have to set the default browser to run the change program. So click "Tools"-"options", in the Web browser items in the selection of a good default browser, rerun the change program, the problem is resolved.

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.