Eclipse Java uses a custom package

Source: Internet
Author: User
How to use custom packages using eclipse

After reading think in Java to chapter 6, I found that according to the process in the book, I defined my own package, loaded the path to classpath, and imported my own package, the prompt package is still undefined. After searching for the Internet for a long time, I only asked questions and didn't answer them. Fortunately, the Java class teacher was quite cool, so I went to consult the teacher.

The method in think in Java should be the method for debugging code using javac command line, but I am using eclipse, so no, in eclipse, you can use the following method to use a custom package:

First:

When the package and the file to use the package belong to the same project, you can directly import the package name.

Second:

When the package to be used is different from the file to be used, you need to export the package to be used as a jar file, such as tools. jar. jar is the same, and then the package is loaded from the properties of the project to use this package.

Procedure:

The package is cn.edu. Bit. Donkey.

1. Right-click the package cn.edu. Bit. Donkey and click Export.

2. Select Java-à JAR file and double-click JAR file (or click Next)

3. Select the file to be added, enter the jar name, and click Finish.

 

At this time, the package is exported successfully, and errors such as compilation errors may be reported, but this does not seem to affect the export.

 

4. Right-click the project name using this package and select Properties.

5. Double-click Java built path à libraries à add external jars

6. Double-click addexternal jars and find your package. Open it.

 

Then you can import your own package.

 

After a week, I can use my own package. So although there are a bunch of bugs in the content, I still want to write a post

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.