The difference between a Java Web project and a Java project

Source: Internet
Author: User
Tags tomcat server

Presumably, when using myeclipse, we should not delve into these two concepts. Just know that Java EE classes are basically Web projects, and Java applications are Java projects. And a lot of people are willing to use myeclipse as a development tool, and do not say that everyone tried to crack this thing, and so many plug-ins at startup loading speed and memory consumption, you are willing to play it? Not reconciled? Continue reading this article! It doesn't matter, you can do something else and don't waste your time here. Of course, this article does not explain how to optimize the MyEclipse, the relevant instructions you can Google a bit.

Web projects are Web page encodings, such as Jsp,servlet,struts, but Java projects are awt,swing of this type of code. The main difference is that the Java files in the Web project are triggered by the Tomcat server, but the main () method in the Java project begins. Another thing is that a Web project requires a server.
I use the classic eclipse+ required plug-in (such as WTP,SVN) +TOMCAT6 build the development environment, not only plug-in on-demand installation, and run fast, memory-intensive.
Now just talk about Java project and Web project, so what's the difference? Answer: No! Is the application of the Java language, but the application is different, then what is their essence? Answer: Post-compilation Path! The virtual machine executes a class file instead of a Java file, so we don't care what kind of project is written in Java files. into Java and the Web two kinds of it?
Starting with the. classpath file, this file is present in every project directory, and very few people open it, so let's take a look. This is an XML file that you can open with a text editor.
A Web project is shown here. Classpath, of course, a master can see its role at a glance
XML code

1. <?xml version= "1.0" encoding= "UTF-8"?>
2. <classpath>
3. <classpathentry kind= "src" path= "src"/>
4. <classpathentry kind= "src" path= "resources"/>
5. <classpathentry kind= "src" path= "test"/>
6. <classpathentry kind= "con" path= "Org.eclipse.jdt.launching.JRE_CONTAINER"/>
7. <classpathentry kind= "Lib" path= "Lib/servlet-api.jar"/>
8. <classpathentry kind= "Lib" path= "Webapp/web-inf/lib/struts2-core-2.1.8.1.jar"/>
9 .....
<classpathentry kind= "Output" path= "Webapp/web-inf/classes"/>
One. </classpath>

<?xml version= "1.0" encoding= "UTF-8"?>
<classpath>
<classpathentry kind= "src" path= "src"/>
<classpathentry kind= "src" path= "resources"/>
<classpathentry kind= "src" path= "test"/>
<classpathentry kind= "Con" path= "Org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind= "Lib" path= "Lib/servlet-api.jar"/>
<classpathentry kind= "Lib" path= "Webapp/web-inf/lib/struts2-core-2.1.8.1.jar"/>
......
<classpathentry kind= "Output" path= "Webapp/web-inf/classes"/>
</classpath>

The XML document contains a root element, the classpath, the classpath, and what information does it contain? The child element is the Classpathentry,kind attribute distinguishes the kind information, src source code, con you look at the back path to know is the JRE container information. Lib is the third-party class library that the project relies on, and output is the location after SRC is compiled.
Since is the Web project, then is the web-inf/classes directory, may use MyEclipse's reunion to say that they are webroot or webcontext instead of WebApp, is there a difference? Answer: Not at all!
Now that you see the true nature of the compiled path, what are the other Java projects and Web projects? Answer: no distinction! Common Java Projects You can do this: <classpathentry kind= "Output" path= "bin"/> see if eclipse was generated like this? This problem has been solved.
Say WebApp directory naming problem, this does not matter ah, the Web project is to publish to the server is right, then the server reads the class file and the paging file, it regardless of the source file, it can not understand the source file. So what does the naming of the WebApp directory matter? Just let the server find the line.
Hope to help the learners. Of course, the IDE's choice is purely a personal preference, only to understand that the essence can have a better choice.

Differences between Java Web Projects and Java Projects (goto)

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.