I want to use some of the java classes contained in a jar, say introcs.jar for example. As seen in Java code to import JAR file, one needs the values of org
and somepackage
to import. If I only have the jar (without any other info.), how can I determine org
a somepackage
? I prefer not to unpack the jar if possible.
It's trivial if org
and somepackage
are known. I know how to add to the classpath
.
(Windows 10 x64)
The linked page shows that the classes are all in the top-level package which has no name. Also, it looks like these classes are meant to be run, not imported. To run them, type:
java -jar introcs.jar <ClassName>
In general, though, any decent jar file should come with documentation saying which package each jar is in. You basically need to know some things about the class you're going to use; at least, what the class does, and how it should be used. And an essential part of "how it should be used" is which package it's in.