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