Eclipse Usage Tips

Source: Internet
Author: User
Tags java web tomcat server

Original: http://blog.csdn.net/chenghui0317/article/details/9417949

Original works, permission to reprint, please be sure to use hyperlinks in the form of the original source of the article, the author information and my statement. Otherwise, the legal liability will be investigated.
Eternal の_☆ Address: http://blog.csdn.net/chenghui0317/article/details/9417949

1. How to create a new Java project or Java Web project

In the project Explorer view in Eclipse, right----and New--and project, and then depending on the dialog box that appears, choose a Java node or Web node, and the IDE creates different projects based on the type you choose.
Enter project name, and now take the example of creating dynamic Web project, and then click the Next button, such as:

In the dialog box above, enter project name, select Target Runtime (the server on which the project is running), module version (model, general select the highest version), etc.

Next click on the Next button to enter the SRC directory structure, you can build it yourself, and then there is a default output folder, the effect is as follows:

This is used to adjust the Java class file compiled after the save directory, by default in the root directory under the build under the classes, generally not recommended here, after all, not safe.

Recommended modification value is webcontent\web-inf\classess


Next click on the Next button to enter the following page:

Context Root: Represents the publication name of the project, which I publish to the directory under Tomcat WebApps, which proves that if I change to the name of WebProject above and then use Eclipse to publish to the Tomcat WebApps directory, More out of the test, and then through the http://localhost:8080/test can be accessed, while the http://localhost:8080/webProject can be accessed. This enables a project to publish two access address functions.

Content directory: Represents the contents of the entire Web project, and Eclipse defaults to webcontent,myeclipse default is Webroot.

Generate Web. XML Deployment descriptor This multi-box indicates whether the deployment description of Web. XML is generated and must be ticked.

Click Finish finished.

2. How can I modify the font of the Java Editor in eclipse?

Choose Window------Preferences and appearance-----Colors and Fonts, in the right-hand side of the dialog, you can change the global format, if you want to modify the Java To find Java-->java editor Text font, then edit it. As follows:

3, how to bind the installed JDK to eclipse, and how to specify the version of the JRE compilation?

Choose Window-----Preferences java--> installed JREs, the list on the right shows all the jres that are already bound, click Add to add a new JDK. As follows:

The other top has this sentence: By default, the checked JRE is added to the build path of newly created Java projects

Translation is: By default, the JRE added to the build path of the newly created Java project is selected. So the selected JDK will be the default JDK support environment for the newly added project.

As for how to specify the JDK compilation version, in the compiler of the sibling menu, select compiler compliance level. This is related to the version, if the jdk1.6 is the highest choice of 6, the other same.

4. How to maintain the jar package in the project and the server running the JDK environment?

Select the item, right---build path---Configure build path, open the dialog box as follows:

In the Source tab, you can re-plan the layout of the items that appear on the left. For example, I will be in SRC under two pieces, a special put code, a special put XML configuration file, then you can do this, Add Folder under SRC, and then delete the previous SRC default layout, save after display:

In addition, the following default output folder can specify that we save the path after compiling our code.

In the Projects tab, you can add the necessary items in the build path.

In the Libraries tab, you can add the jar package you need, click Add jars, or in the project directory, under the WebContent-----web-inf----lib directory to copy and paste directly.

Alternatively, if you need to modify the JDK version, you can choose the Add Library-> JRE System Library to select the JDK directory that we have installed.

In the Order and Export tab, you can specify the sort that each root directory displays in Project Explorer.

5. How do I view the version of Eclipse?

In the root directory of Eclipse, open the. Eclipseproduct, which shows version=3.7.0 that the IDE version is 3.7.0

6. How do I add a tomcat server to eclipse?

Choose Window-----Preferences server-to-Runtime environment, which is responsible for adding specific physical paths to servers such as Tomcat, as follows:

7, take Tomcat as an example, how to add the Servers service window?

Select Window--Show View--Servers. Eclipse loads the Servers window and then clicks the New Server Wizard hyperlink to add the corresponding Tomcat server, as follows:

If there is no runtime environment need to manually add, some direct choice is good. Then click Finish finished.

8. How can I use Tomcat to publish projects and run them in eclipse?

Based on the servers and bundled tomcat servers that we have created earlier, right-click the Expand Feature List below:

Debug: Running the server in debug mode

Start: Run the server in the first way

Publish: Publish Project

Clean: Cleans up the entire Tomcat server, this step will include publishing the project and updating the Tomcat configuration to the physical directory of Tomcat, so since we have Tomcat configured in Eclipse, Then the configuration file information should be in the servers project under this directory to modify, or it will be clean when the previous configuration all covered out

Add and Remove: Items added here will be copied directly to the WebApps directory under the Tomcat directory

9. Why is the project published in Eclipse not found in WebApp?

Because Tomcat is configured in Eclipse by default, the project is published to the. Metadata\.plugins\org.eclipse.wst.server.core\tmp0 inside the WebApps, so of course you can't see. So you need to double-click the built Tomcat server and re-establish the Tomcat's publishing path in the server Locations in the popup page, as follows:

The first default option is to publish the project to the metadata directory in the workshop.

The second option is to publish the project to our own specified directory, which must be specified in the root directory of Tomcat, or the project that needs to be started cannot be loaded when the project is started.

The third option is to publish the project to our own specified directory, not necessarily the Tomcat installation directory.

In particular, if you find that these buttons are disabled, re-clean the server and reopen it.

10. How do I specify the time-out for Tomcat startup projects?

You need to double-click on the built Tomcat server and specify it in timeouts on the popup page as follows:

11. How many ways does the Tomcat deployment project have?

There are basically two types, one is to copy the project's WebContent directory to the WebApps directory under the Tomcat root through Eclipse as a bridge, and the startup server will publish the project.

Another way to publish a project is by binding a virtual directory, as follows:

Add <context path= "/project" docbase= "D:\project\projectName\WebRoot" to the <Host> tag in Tomat's Conf/server.xml Reload= "true"/>

Note that the context of the first letter must be capitalized, the other docbase specified is the project Webroot or webcontent directory must be so, because the read Web-inf and compiled files are to be found in the root directory, can not find the words will not be error, just publish unsuccessful, Path is the access name for the virtual directory, and reload indicates whether overloading is supported.

12. How do I set the default encoding for Eclipse? How do I set the encoding format for a single item or a single file?

Encoding format What's the most annoying, often for this annoyance, to set the Eclipse default encoding, that is, every time you create a new project, all the code is defined by itself, such as UTF-8

Select Window---Preferences---Workspace, find the Text file encoding select other to UTF-8, save.

As follows:

To reset the encoding for the entire project, select the item--right---Resource, in the Text File encoding box, select Other to UTF-8, and the entire project will be automatically re-build once saved.

As follows:

The same is true for individual file modifications.

13. When debugging the program in Eclipse, why is the Workerdone (this) in the Threadpoolexecutor, and this place stops, but does not set the dug point in this place?

As follows:

Because the default debug time in Eclipse specifies a debug timeout of 3000 milliseconds, which is passed into the class. So modify the time-out to be good.

Select Window------Preferences----Debug, find debugger timeout after modifying parameters, slice as follows:

Similarly, Launch timeout is the setting for running timeout.

14. How do I search for files in eclipse?

There is a search button in the Eclipse top menu bar, click In, and then select the File Search tab in the Popup dialog box, as follows:

There are many parameters in it, including:

Containing text: Specifies the keywords that you want to search, followed by regular expression and case sensitive to indicate whether regular expressions and casing are supported

File name Patterns: Specifies the format of the files that you want to search, such as the servlet suffix of the servlet input: *servlet.java

Scope: Specifies all directories, by default, in the current workspace

Then click Search, you will be in your own selection directory according to the keywords you entered to find out whether the specified file exists, the presence will be displayed on the search results page.

Eclipse Usage Tips

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.