Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the .classpath file in the eclipse project

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the usefulness of the .classpath file in the eclipse project. It is very detailed and has certain reference value. If you are interested, you must finish it.

1 preface

When using eclipse or myeclipse for java project development, there is a .classpath file under each project (project), so what is the use of this file?

2 function

Classpath file is used to record all information about the project's compilation environment, including: source file path, compiled class file storage path, dependent jar package path, running container information, dependent external project and other information. If the file is deleted, eclipse cannot identify the project as a normal java project, only as a normal folder, which will not work properly.

3. Classpath content

The .classpath file is also a content file in xml format, which is roughly as follows:

① takes "classpath" as the root node, and each "classpathentry" node represents a description.

② each "classpathentry" indicates the type with the "kind" attribute, and the "path" indicates the path.

All the contents of the files above ③ are changed depending on the content of "Java Build Path" in the project, that is, all operations on "Java Build Path" will be reflected in the contents of the file.

Now let's analyze the meaning of each node of the file content in detail.

3.1 kind= "src"

Src: that is, source source file, represents a source file, path= "src" is a relative path, relative to the .classpath file itself, that is, path= "src" means that the folder src is in the same directory as .classpath and represents the source file.

The operation of kind= "src" corresponds to the "Source" tab page of "Java Build Path"

As shown in the following figure, add a folder bin as the source file, and the .classpath file adds content

The content is added as follows:

Of course, if you modify or delete it accordingly, the contents of the .classpath file will change accordingly.

In addition, when the specified property combineaccessrules= "false" is, it represents the introduction of external project, as follows

The corresponding page tab, where path= "/ mybatis" is under the corresponding workspace

Absolute path.

3.2 kind= "output"

Output is used to specify the class file storage path of compiled java source files in the following format

Path: represents the path where the class file is stored, which is also the path relative to the .classpath file. Find "WebContent/WEB-INF/classes" and you can see the storage of the class file.

If you modify the output file path, the corresponding content will also change.

Change it to: spring-mybatis\ WebContent\ WEB-INF\ newclasses

Then the contents of the .classpath file are modified to:

The path where the class files are actually stored will also change.

3.3 kind= "con"

Con is the container, that is, the container in which the program runs, or the running environment is also OK. It is actually specified in the configuration installed JREs at the beginning of the Myeclipse (usually we specify JDK), but here we actually use the jar package in the JRE under JDK, which is the corresponding statement JDK_HOME/jre/lib. The details are as follows

The corresponding operation tab is as follows

3.3.1 JRE configuration

Path= "XXX" is used to specify the usage of the jre container. You can choose different sources of jre, and the actual values of path from different sources may vary.

If ① selects "Workspace default JRE (jdk1.7)", the value is

Path= "org.eclipse.jdt.launching.JRE_CONTAINER"

If ② selects "Alternate JRE", the value is

Path= "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7"

The last jdk1.7 is my custom JRE name

③ Select "Execution environment", that is, select the built-in jre that comes with eclipse. The value is

Path= "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"

The last JavaSE-1.7 is the built-in JRE name of the system

Also, the attribute value name= "owner.project.facets"

It should be a template that specifies the specific use of the JRE container, using "java" by default, without exploring specifically.

3.3.2 Server Runtime configuration

Similarly, the configuration of other containers is the same as above, such as the configuration of Server Runtime container. The running environment of tomcat container is configured below.

3.3.3 Web App Libraries configuration 3.3.4 User Library configuration 3.4 kind= "lib"

Kind= "lib" is used to specify the Referenced Libraries on which project depends. As shown in the figure, a jar package has been added.

Then the content of the corresponding .classpath file is increased.

Where path specifies the relative path of the dependent jar.

3.5 order

The order of the nodes in the .classpath file is controlled by tab-Order and Export, and a different order may cause problems in loading class files, usually with the source code first.

The above is all the content of the article "what is the use of the .classpath file in the eclipse project?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report