Use eclipse as the development environment for Jakarta Tomcat

Source: Internet
Author: User
Use eclipse as the development environment for Jakarta Tomcat

A Method to quickly integrate eclipse and tomcat


Level: elementary

Geoffrey R. Duck, software developer

June 01, 2004

Eclipse is a good Java development environment. Eclipse Tomcat plug-in can help programmers better organize and integrate Java and web development projects. This article will gradually introduce the installation process of Eclipse, Jakarta Tomcat, and an eclipse Tomcat startup plug-in (which can be integrated with eclipse and tomcat.

Reasons for using eclipse and tomcat

Since a long time ago, I have been using eclipse for development. I found that eclipse is one of the best tools for my Java development work. I used to be a Java programmer with a Linux background and could only program with VI and JDK. At that time, writing and debugging Java programs was a very tedious task. Now with the help of Eclipse, I can easily build a Java-based prototype quickly. Then I thought about why not integrate the JSP development environment into the eclipse environment? This makes it easier to write Java code and JSP code. The purpose of this article is to save the time for JSP developers to set the working environment for eclipse and tomcat.



Back to Top

Download Components

When setting the environment for eclipse and tomcat to work together, you need to use several components. See table 1.

Table 1. components used in this article and their version numbers

Components Version
Eclipse IDE 2.1.2
Sun Java SDK 1.4.1 1.4.1 _ 06
Tomcat 5.0.16
Sysdeo eclipse Tomcat startup plug-in Sysdeo Tomcat plugin 2.2.1

Download the required components. The references section of this article lists the sites that can download these files. These sites are also accessible when published in this article.

Eclipse IDE:Eclipse IDE is used as the development environment for JSP pages and java files. Eclipse is a very simple and easy-to-use IDE environment with many features that can help programmers quickly write and debug Java programs. After the Tomcat plug-in is added, this IDE is an excellent tool for managing the entire web project (including HTML and JSP pages, icons, and servlets.

Sun SDK:A required SDK for Tomcat Eclipse plug-in to work properly. This SDK may not be Sun SDK, but must be an SDK (not a JRE, because it cannot work normally ). To enable tomcat to work normally with Eclipse, a Java compiler is required in the SDK.

Tomcat:Tomcat is required to drive the JSP page. Tomcat is a very good servlet engine, which can be freely downloaded and easily installed.

Sysdeo eclipse Tomcat startup plug-in:This is one of the many Eclipse plug-ins used for Jakarta Tomcat. This is a very good plug-in, which saves me a lot of time and can be well integrated with web projects and Java code. I usually use eclipse to write these code.



Back to Top

Install

Decompress all components

After downloading the required components, the next step is to decompress each file. Decompress these files and put them all in the same directory, so that you can find all the decompressed files.

Copy the Tomcat plug-in to the eclipse/Plugins directory.

After all the files are unzipped, copy the Tomcat plug-in directory to the Plugins subdirectory In the eclipse directory. The directory name I extracted from the sysdeo ZIP file is com. sysdeo. Eclipse. atat_2.2.1. Copy the entire directory to the eclipse/Plugins directory.

Install SDK

Next, install the downloaded SDK. The Eclipse plug-in of Tomcat requires that the JRE set in the eclipse workspace be a real SDK with a Java compiler. This is a requirement for using the sysdeo Tomcat plug-in. After installing the SDK, you can start the eclipse workbench.

The default JRE of eclipse must be from an SDK

The Tomcat plug-in requires that the default JRE set by eclipse be an SDK, otherwise the Tomcat plug-in will not work properly.



Back to Top

Configuration

Set the JRE of This SDK to the default JRE of Eclipse.

Before starting eclipse, You need to configure some options on the preferences page of the workbench. SelectWindow> preferencesTo open the preferences dialog box, as shown in 1.

Figure 1. Eclipse preferences dialog box

Select the Java option in the Tree View on the left. Expand the Java element and select installed JRE, as shown in figure 2.

Figure 2. JRE preference settings

Click "add" and switch to the JRE directory installed in the installation phase configured above, as shown in 3. Click "OK ".

Figure 3. Add a JRE to the preference settings of eclipse

Select the check box on the edge of the JRE added during SDK installation, as shown in figure 4. In this way, set JRE to the default JRE used by eclipse. The Tomcat plug-in works only when this step is set correctly. The Tomcat plug-in requires that the default JRE selected in these settings be an SDK.

Figure 4. Set the default JRE for eclipse and tomcat

Set Tomcat home variable in Tomcat preferences

Next, set the preferences of the Tomcat plug-in. The preferences dialog box is still displayed. Select "Tomcat" from the menu on the left, as shown in Figure 5.

Figure 5. Set preferences of the Tomcat plug-in

Select the tomcat version from the preceding single-choice button. The tomcat version I use is 5.0.16, so select the last single-choice button "version 5.x ".

You must set the Tomcat home variable. Click the "Browse" button on the side of the "Tomcat home" dialog box to browse the root directory of Tomcat that was just extracted, and then click "OK. The configuration file is automatically selected and the corresponding content is added in the dialog box. If you want to select a different configuration file for Tomcat, you can browse these files now. Otherwise, the default value is used normally.

Now we have implemented the minimum requirements for using the eclipse and sysdeo Tomcat launcher plug-ins to start and run tomcat. View other Tomcat parameter settings in the following eclipse preference dialog box. Note that many other options are available in Tomcat parameter settings. For example, you can add a parameter to the JVM used by the Tomcat server, select a Java project from the workspace to add it to the Tomcat classpath, and perform some settings to allow tomcat to manage applications.



Back to Top

Test both Tomcat and eclipse

Create a new Tomcat Project

To perform integration tests on Tomcat and eclipse, you can start by creating a new project. SelectFile> New> ProjectAnd check the wizard content of the new project. There is a new project "Tomcat Project" in the Java section of the Project Wizard (see figure 6 ). Select this option and click Next.

Figure 6. Create a New Tomcat Project

Name the new Tomcat project. For example, "atatproject", 7. Click Next.

Figure 7. Set the Tomcat project name

Now we can see that you can specify the name for the context of the web project, and you can also specify a sub-directory as the root directory of the Web application. Now we keep the default value unchanged (see figure 8 ). Click Finish.

Figure 8. Set the root directory of the Tomcat web application

A project with a war structure is created in the workspace, as shown in figure 9.

Figure 9. Created Tomcat Project

Create a JSP file for testing

The easiest way to test the installation process is to create a new file in the root folder of the War Project. Create a new file, which is called "index. jsp ". To implement this function, select your project in the workspace and right-click it. SelectNew> File, Name it "index. jsp", as shown in 10, and click Finish.

Figure 10. Create an index. jsp file to test the configuration

Add the content in Listing 1 to the index. jsp file and save the file.

Listing 1. index. jsp file example

Use the sysdeo plug-in to start Tomcat

Now the great moment is coming. To start the Tomcat server, simply click Start tomcat in the toolbar, as shown in Figure 11. You can also select the Tomcat menu in the main menu and then select start Tomcat ".

Figure 11. Use the sysdeo plug-in to start the Tomcat server

The Tomcat server will be started now, And the startup text will be displayed in the console view of the eclipse workbench, as shown in 12. Check the startup log and check for any errors.

Figure 12. Tomcat startup information displayed in the eclipse console View

Start the browser and view the index. jsp file

After the server is started, start a web browser. Go to the URL http: // localhost: 8080/atatproject. A page is loaded, and you will see a message similar to the following:

Todays date is 30 and this JSP page worked! (The date displayed on my screen is 30, because today is the 30th .)



Back to Top

Conclusion

Now you have correctly configured eclipse and configured it so that it can work with Jakarta Tomcat. Now we can quickly develop and test the integration of JSP and Java code. This excellent program can improve our productivity. Using eclipse to write Java code and integrate it with Jakarta Tomcat makes JSP development more interesting and easier.

References

  • For more information, see the original article on the developerworks global site.

  • Download eclipse from the eclipse download page.
  • Download Tomcat from the Jakarta download page.
  • Download Sun SDK 1.4.1 from Sun's Web site.
  • "What is eclipse? What can it do? "(DeveloperworksSeptember 2001) provided a lot of information for eclipse beginners.
  • "Tomcat story "(DeveloperworksSeptember 2001) contains a wealth of background knowledge about Jakarta Tomcat.
  • The Jakarta Tomcat page contains a lot of information about tomcat.
  • InDeveloperworksIn the open source code project area, you can find more articles for eclipse users. You can also referAlphaWorksDownload the latest eclipse Technology in.
  • In the open source code area of developer bookstore, you can find hundreds of books on open source topics, including several books on Eclipse and books on Struts application development.

About the author

 

Geoff duck is a software developer at IBM Canada Ltd. He studies E-Commerce innovation at the IBM center in Burnaby, BC, Canada. Geoff focuses on Java programming and design, as well as web-based application development.

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.