Tomcat Installation-free environment variable configuration and tomcat configuration and testing under Eclipse

Source: Internet
Author: User
Tags typing net tomcat server

Tomcat is now a popular open source and free Web application server, on my computer for the first time to install Tomcat, and then after the online tutorial and their own groping, the process is re-recorded, so that if you forget to be able to view at any time.

Note : To be clear first, Tomcat is closely related to Java, so install the JDK and set the JDK environment variables before installing it, because the JDK is already installed and the JDK environment variable is set up, so there is no more narration here. Just describe the environment variables I set up:

Java_home:f:\jdk_kit

CLASSPATH:.;   %java_home%\lib\dt.jar;%java_home%\lib\tools.jar; (There is a point at the front)

At the top of the path, add:;%java_home%\bin; (There is a semicolon in front and back)

Enter java-version in the cmd window to see if the environment variable is set successfully:

My JDK version is 1.8.0_45.

Well, this configures the environment variables for the JDK. Here's how Tomcat starts.

===========================================================================

First Baidu search Tomcat, to Apache's official website download, here selected is the latest version Tomcat8

Click to select the ZIP format, that is, free installation version, because my machine is 64-bit Windows, so choose the following:

After downloading, unzip to my custom tomcat_8.0.24 folder under F drive:

When you're done, start configuring Tomcat's environment variables and some settings:

Create a new tomcat_home in the environment variable with a value of the directory where TomCat resides, that is, F:\TomCat_8.0.24

In addition to the new Catalina_home and Catalina_base, where Catalina_home is the installation directory of Tomcat, Catalina_base is the working directory of Tomcat,

For the time being I do not differentiate, so set its value to%tomcat_home%

For the difference between catalina_home and catalina_base, please check the reference blog separately

such as the difference between catalina.home and catalina.base, or the difference between catalina_base and catalina_home, etc.

After configuring the environment variables for Tomcat, we will configure some of the files in Tomcat:

Open the Bin folder under the Tomcat installation directory and we want to supplement Startup.bat and Shutdown.bat,

To edit these two files, add the following two lines before the first line of the file, that is, @echo off:

SET java_home = jdk Directory

SET catalina_home = Directory of Tomcat after decompression

For my system, it is configured as:

SET Java_home = F:\JDK_Kit
SET Catalina_home = F:\TomCat_8.0.24

After completing this step, you can click Startup.bat to start the server, click Shutdown.bat shut down the server, of course, this is just one of the ways,

Several ways to start and close Tomcat are described later.

Next, you should add Tomcat to the service

The zip version downloaded from the web requires Tomcat to be added to the service, or Tomcat cannot be configured and the Tomcat8w.exe in the Bin folder cannot be opened.

As you can see from the Task Manager, click on the Star button on this Tomcat8w.exe program to start Tomcat8.exe.

The way Tomcat joins the service is to navigate to the directory where the bin folder resides in cmd and enter Service.bat install

You will then see a series of environment variables just configured, and the hint that Tomcat has been installed:

Note: Each line in this should clearly show the value of each environment variable setting, if there is no value, only the double quotation mark "", is an error,

In this case, although the Tomcat8w.exe can be turned on, clicking the Start button does not start the service (that is, you cannot switch to the state that the Stop button can press).

You can also use CMD type services.msc call up service to see if there is Apache Tomcat8 (default is manual start, if you start automatically, boot Tomcat will start in the background)

To the current location, the basic configuration is over, and there may be some small configuration, such as setting Tomcat's username and password, which will be said later.

Tomcat Start-up

After we have configured Tomcat, we care about whether these configurations are successful, so we need to verify that Tomcat starts up with several boot methods:

First: start in command console cmd and enter the following statement in CMD to turn the Tomcat server on or off:

Net START service Name

NET stop service Name

Tomcat's service name is the tomcat+ version number, such as TOMCAT6,TOMCAT7 ... Because my Tomcat version is Tomcat8, the service name here is Tomcat8

Second: use startup.bat This batch file to open the Tomcat server, use the Shutdown.bat batch to shut down the Tomcat server, for this way as mentioned above to join

two words Set java_home = JDK directory and set catalina_home = Directory of the extracted Tomcat

Third: go to the bin folder of the Tomcat directory, open the Tomcat7w.exe program, select the "Star" button in the open window to open the server, select the "Stop" button to shut down the server.

Verification of Tomcat

Knowing the various ways Tomcat is open, we can verify that Tomcat is working and choose any of the ways Tomcat starts, such as typing net start Tomcat8 in cmd

Prompt the Tomcat server to start successfully, then open the browser, enter localhost:8080

If Tomcat is able to work, you can open the Tomcat Web site and make sure Tomcat is working correctly:

After the test, don't forget to turn off the server and turn it off by the way you choose to open it:

Finally, say something small:

1. Tomcat can set the user name and password, in the Tomcat directory in the Conf directory, there is a tomcat-users.xml file, click to edit the user name and password

Add a line to the </tomcat-users> on the last line:

<user username= "admin" password= "123456" roles= "Manager-gui"/>

You can set the username and password to admin and 123456

  

2. The default port number for Tomcat is 8080, and you can open Server.xml in the Conf directory in the Tomcat directory to find this line:

  

You can see that the port number is 8080 and you can change the port number to any port number.

But the port number changed here doesn't have to change in eclipse, I didn't test it, but I saw an article:

Http://www.2cto.com/kf/201308/232699.html, be free to test it.

===============================================================================

These are all the processes that Tomcat has downloaded to the configuration, finally started and validated, and if you want to develop with eclipse with Tomcat, you need to configure Tomcat in eclipse

First start eclipse, click "Windows", select the last item "preferences", open the Preferences window, click "Server", select the last item in its subkey "Runtime enviroments",

Click on the "Add" button in the window to add the server:

Select the Tomcat server to configure:

Set up the directory where Tomcat resides and the JRE used:

This completes the relationship between Eclipse and Tomcat, but the Tomcat server has not yet been created.

To create a tomcat server, you can click on the "Servers" tab on the toolbar on the console below eclipse, and you will be prompted with the following:

Then we will click on the prompt, the following window will pop up:

Eclipse automatically helps us select the "Tomcat v8.0 Server" option, as we do not have resources now, so just click "Done" to see the "Servers" tab at this point:

After the creation of the Tomcat server, you also need to configure the Tomcat server, double-click the "Servers" tab created under the server, the server will pop up the "Overview" window, find the "server Locations" configuration options, select "Use Tomcat installation option so that the following "server path" is automatically set as the Tomcat Server installation directory, then manually set "Deploy path" to "WebApps", This completes all the configuration of the Tomcat server in eclipse:

We can click on the green button, this button is to start the server, we will see the "Servers" tab under the status of the server has been changed to "start", and the end of the button is also activated:

While clicking on the "Console" tab, we can also see some information:

Note that Tomcat has started successfully in Eclipse, then open the browser and enter localhost:8080:

You can see that the Tomcat server is ready to work:

This means that Tomcat has been configured successfully and functioning properly in eclipse.

====================================================================================

Postscript

Some of the problems that may arise:

After you double-click the server to open the Overview window, you can see that some ports can be set in the right part of the interface, with Tomcat ports, HTTP ports, and AJP ports

1. Sometimes the prompt (8005, 8080, 8009) port is occupied, it may be because the other software to occupy one of the three ports (this is the most likely cause, most likely is JAVAW this process to occupy),

So as long as it is forced to close, of course, there are other reasons, you can see http://blog.csdn.net/zhouyingge1104/article/details/7243363 this blog post.

2. There are times when I want to modify the port to pop up the following window:

  

I don't know why, but I can change it once in a while.

3. One of my own doubts is that the Tomcat port in the server "Overview" window is 8005, why do I have to go to the browser to lose 8080 instead of the input 8005, which is my question

These questions, I will take the time to search for a good answer, today will be here first ...

Tomcat Installation-free environment variable configuration and tomcat configuration and testing under Eclipse

Related Article

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.