Java – access referenced libraries from packages in eclipse

If I save the class in the default package, I can only access the referenced library class If I try to access it from any other package, I get "classname cannot be resolved" Any idea why this happens

Solution

The software package comes from the standard library of introcs courses at Princeton University

If you follow the FAQs on the page http://introcs.cs.princeton.edu/java/stdlib/

Download the package jar file: http://introcs.cs.princeton.edu/java/stdlib/stdlib-package.jar

Right click the project folder and add an external jar

import edu.princeton.cs.introcs.*;

Add the above line to the class that needs to reference the class The first line refers to the correct package name, and the * wildcard will import all classes in it

I hope it helps

//Edit – if you right-click the project folder and use organization import, it will be faster, so you don't have to add it to each class manually

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>