I can only access referenced library classes if I save my classes in the default package. If I try to access them from any other package I get "className cannot be resolved". Any idea why this could happen?
That package is from the standard library of Princeton's IntroCS Course after a quick Google.
If you follow down to the FAQ on the page http://introcs.cs.princeton.edu/java/stdlib/
Q. If I use a named package to structure my code, the compiler can no longer access the libraries in stdlib.jar. Why not? A. The libraries in stdlib.jar are in the "default" package. In Java, you can't access classes in the default package from a named package. If you need to use our libraries with a named package, you can use the packaged version stdlib-package.jar.
Download package jar file: http://introcs.cs.princeton.edu/java/stdlib/stdlib-package.jar
Right click project folder and add external JAR.
import edu.princeton.cs.introcs.*;
Add above line to the classes where you need to reference the classes. The first line references the correct package name and the * wildcard imports all the classes within it.
:) Hope that helps.
//Edit - If you right click the project folder and use "Organize Imports" it will be faster so you don't have to manually add to each class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With