Java Engineering catalog Problem and path problem understanding under Eclipse

Source: Internet
Author: User

What folders are available for Java projects under 1.Eclipse?

A: When you new Java project, the SRC source code directory is created by default and a bin directory is created as the output directory by default, and the output directory refers to the generated class file and profile address.

So the Java project created by Eclipse, the default is two folders, src and bin.

2. When you click Eclipse Runtime, the Java JDK will compile by default and put the compiled Java file, the generated class file into the Bin folder under the project directory, and end with the. Class name.

Note: Even if a class has bug errors, it cannot be compiled through. However, as soon as you click Compile Run, the class file will be generated under the Bin folder.

3. The most important directory is the bin directory, not the SRC directory. The bin directory is the output directory of the entire project, and the output directory means that both the compiled class file and the Propertier file used in the project will eventually be output to the bin directory.

The final result of the project is the jar file, the jar file is also only the class folder, and there is no SRC folder, but the SRC directory under the conversion of all the package name to a folder saved in the bin directories, Other test root directories, such as the Config folder that you create yourself, do not exist in the bin directory of the jar package, but all other folders under the non-SRC folder are saved to the bin directory.

The 4.java compiler (JDK) can compile the project and all the prerequisites for organizing the project are: Classpath. The Java.exe virtual machine has a CP parameter, and the Java project generated by Eclipse will have a classpath parameter, and eventually eclipse will pass its classpath parameter to the Java.exe's parameter CP for the Java Virtual Machine run control. For example, the folder config you created under Project test will not be read because the eclipse default classpath only includes the SRC directory, the bin directory jdk directory, and the dependent Jar package directory. This is why when we introduce a jar package, we must add to build path, including the add to source when creating the folder. All this is to add the Claspath path inside.

5.JVM most red will be output to the bin directory according to the path under Classpath. Including the introduction of the jar package and so on.

6. So classpath is the foundation of the Virtual Machine compilation project, which is the basis of the virtual machine compiling organization project.

7.classpath is the basis for a virtual machine to compile an organization project. The project root directory is the basis for creating files that introduce paths.

8.buildpath is Classpath,buildpath is classpath. is the root of the JVM-compiled organization build project. Only add the BuildPath (classpath) to be read by the JVM, that is, to be read by the code.

8. Each project has a default root path. The default root directory under Eclipse is test, which is directly under the project directory. While the generated jar package, the default root directory is under bin.

9. Look at the. classpath file under the project folder: 4 part, SRC ask price, bin file, JDK path, jar package path

<classpath>
<classpathentry kind= "src" path= "src"/>
<classpathentry kind= "Con" path= "org.eclipse.jdt.launching.jre_container/ org.eclipse.jdt.internal.debug.ui.launcher.standardvmtype/javase-1.8 "/>
<classpathentry kind= "Output" path= "Bin"/>
</classpath>

10. In the project code, how to get the absolute path of the project or file or class?

A: Because of the existence of classpath, so when we read the configuration file or involved in the file path operation, in the code only need to write relative relative path, relative path is referring to the path of classpath, that is, referring to the final Bin folder path. If you want to get an absolute path, you can get the absolute path of the class at any time through the ClassLoader of the class, Class.getclassload (). GetResource ("");

11. By the way, how does eclipse invoke the local JDK's and local JDK's virtual machines, depending on your locally configured java_home environment variable, eclipse will automatically read this environment variable address. And then compile and run the project. In turn, passing Eclipse's own classpath to the JVM's CP parameter

Java Engineering catalog Problem and path problem understanding under Eclipse

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.