Eclipse for Java EE tutorial, eclipseee
1. The current environment is as follows:
Computer system type: 32-bit Operating System
JDK version: jdk1.8.0 _ 20
Tomcat version: apache-tomcat-8.0.12
Eclipse version: eclipse-jee-luna-SR2-win32
2. JDK environment variable settings:
Create a variable: JAVA_HOME -- C: \ Program Files \ Java \ jdk1.8.0 _ 20 (set this variable based on the jdk path you have installed)
Classpath --.; % JAVA_HOME % \ lib \ tools. jar
(Do not forget that there is a small dot above. Note that all characters in the variable value are English characters)
Edit variable: Path -- % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin
(ALL variable values are separated by semicolons, but are not ended by semicolons)
Determine whether jdk settings are successful or not:Run cmd and enterJavac, The following (1) indicates that the configuration is successful.
Figure (1)
3. Configure the eclipse Server:
Check whether JDK (2) and Web Services (3) have been configured.
Figure (2)
Figure (3)
Configure Server Runtime Environments. If it is null, clickAdd, And the (4) dialog box is displayed:
Figure (4)
Next, click Next, (5), and then Finish:
Figure (5)
Final result (6 ):
Figure (6)
Configure Tomcat serverFor example, (7) the Server column shows the status of the added Server. If the status is blank, that is, the Server is not added, it is in the blank space.
Right-click -- new -- Server, and the following dialog box is displayed (figure (8 )):
Figure (7)
Figure (8)
Specifically, Tomcat should select its own version. Here it is Tomcat 8.0, the host name below is the default value, and the Server name is the default value. Of course,
You can also change it to the name you want. Then, select the corresponding Tomcat version in the following Server runtime environment. If not,
You can click Add Configure runtime environments to Add it. For more information, see step 4.
Click Next to add a project, or click Finish. Then you can see the effect of (7 ).
A Server file is displayed on the sidebar. This is a configuration file about the Server. You can manually modify the Server configuration in it (9 ).
Figure (9)
How to open the Package Explorer View:Window -- Show View -- Other -- Java -- Package Explorer
Double-click Tomcat in figure (7) to open the Server configuration page. (10 ):
Figure (10)
Note:You must select your Tomcat installation path for Server Location. The Start Time Value in Timeout can be larger to avoid service startup Timeout errors.
Save the modification.Otherwise, even if the service is started, it cannot be accessed. Then, you can access the server to check whether the configuration is successful. Normally, it works.
So far, Eclipse has been configured.
4. Create a project: demo
New -- Dynamic Web Projece -- Next
As shown in (11), You must select this check box. Otherwise, the web. xml file cannot be automatically generated.
Figure (11)
Click Finish to create a project.
Create a JSP File, right-click WebContext -- New -- Other -- Web -- JSP File -- Next -- index. jsp -- Finish
In this case, The following error may occur in the JSP file: "The superclass" javax. servlet. http. HttpServlet "was not found on the Java Build Path ",
This is because no package is added.
Solution:Right-click the demo project -- Build Path -- Configure Build Path -- Libraries -- Add Library -- Server Runtime
-- Next -- Apache Tomcat v8.0 -- Finish -- OK save
If the project does not have a JSP page view file, create a new one. Then,Publish the project on the serverThe procedure is as follows:
(1) Right-click Tomcat server -- Add and Remove -- As shown in (7). The displayed dialog box is displayed, and select the project to be released -- Add --> Finish on the left.
(2) Start the server. Right-click Tomcat -- and click Publish to debug or Start.
(3) test project. Enter an address in the address bar to test the project.
So far, the entire Eclipse configuration and simple project examples have been completed.