Eclipse and myeclipse are associated with the Java jar package and the source file and the doc file. [for example, there is a picture with the Truth]

Source: Internet
Author: User

To prevent problems, let's start from scratch.

1. Download JDK

URL: http://www.oracle.com/technetwork/java/index.html

2. Configure Environment Variables

1. Choose my computer> Properties> advanced> environment variables> system variables to add the following environment variables:
2. The java_home value is [D: \ Program Files \ Java \ jdk1.6.0 _ 18] (the directory where you install JDK)
3. The classpath value is: [.; % java_home % \ Lib \ tools. jar; % java_home % \ Lib \ DT. jar; % java_home % \ bin;] (fixed)
4. Path: append [% java_home % \ bin;] at the beginning ;]

The image above is correct. Although these configurations are not necessary, configure them as much as possible. In this way, you can use DOS to compile and run Java.

3. Configure Doc and source in eclipse

Eclipse has the ability to directly view the Java documentation and Class Library source code, but you have to manually add it. Next we will summarize how to add the Java documentation and Class Library source code in eclipse.
1. Window-> pereferences-> JAVA-> installedjres. the right window displays the loaded JRE.
2. Select the JRE version to be set and click "edit". The JRE editing window is displayed.
3. Add javadoc: select all the packages under jresystem libraries, and click the "javadoclocation" button on the right to bring up the javadoc setting window. Select "javadocurl" single region, click "Browse", select the docs/API directory, and click "OK"
4. Add Source: select all the packages under jresystem libraries, and click "sourceattachment" on the right to bring up the sourceattachment Configuration window. In a single click, select the src.zip file in the Java installation directory and click "OK"
5. OK and OK.
After adding Javadoc and source, you can use the shortcut key "Shift + F2" in eclipse to quickly call up the API documentation of the selected class; you can use Quick F3 (or right-click on the class and view the Declaration now) to open the source file of the class.

See my configuration as follows. Note: This figure is the Chinese version of the DOC file downloaded by myself, and then configured

4. Configure Doc and source in myeclipse [the following uses struts2 configuration as an example]

1. Create a WEB Project

2. Download objects

3. Unzip this file under the struts2-2.2.1-all Struts-2.2.1 apps under the struts2-blank-2.2.1.war unzip, and then the WEB-INF under the classes struts. xml file copy to the WEB Project

4. Copy all jar files in the Lib file under the struts2-blank-2.2.1.war file under the WEB-INF file to the Lib under the WEB Project. For example

Modify the Web. xml file in the WEB Project

<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><display-name></display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><filter>        <filter-name>struts2</filter-name>        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping></web-app>

Note: In the above Code, some of them are all copied from the Web. xml file under the struts2-blank-2.2.1 under the WEB-INF. [Copy the code below]

    <filter>        <filter-name>struts2</filter-name>        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>

5. Modify the Struts. xml file as follows:

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><constant name="struts.devMode" value="true" />    <package name="default" namespace="/" extends="struts-default">        <default-action-ref name="index" />        <global-results>            <result name="error">/error.jsp</result>        </global-results>        <global-exception-mappings>            <exception-mapping exception="java.lang.Exception" result="error"/>        </global-exception-mappings>        <action name="hello">            <result>            /Hello.jsp            </result>        </action>    </package>    <!-- Add packages here --></struts>

In this way, it is okay to configure the WEB Project to the server.

But what if I need to check the source code? What should I do if I want to see the doc?

6. Configure the Java source file in myeclipse

Right-click any jar package in this web project [take the jar package of struts2-core-2.3.8.jar as an example], then click Properties, and then the following appears

You can configure everything on the left.

The first line: Java source configuration [E:/java_web/struts2-2.2.1-all/Struts-2.2.1/src/CORE/src/main/Java] --> java_web is one of my Directories

The second line: Java Doc configuration [file:/E:/java_web/struts-2.3.8-docs/Struts-2.3.8/docs/struts2-core/apidocs/] --> java_web is my directory

Although the previous version is not the same, it does not affect usage. We recommend that you use the latest official version. 2.3.8.

Http://struts.apache.org/download.cgi#struts221

Screenshot

Isn't this all done? Is it easy?

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.