Reputation: 3628
I'm pretty new to java and with some googling I haven't found an answer. I have a JAR file that is correctly added to my classpath. How am I supposed to know what the package name for the jar file is if it is never given to me?
Upvotes: 0
Views: 1887
Reputation: 1033
If you are using eclipse, when you type some class/interface that your class didn't import yet, eclipse will do the red highlight. You just need to hit ctrl+1 over it, a list will show up with some options like
Import 'class you are trying to use' (full package path to class)
Or you could refer to that jar documentation on which package to import. Bottomline is that typing by hand is not very productive, ctrl+1 and ctrl+shift+o are your friends(if you are using Eclipse).
Upvotes: 1
Reputation: 1849
jar is a normal zip file. open this file and look at the directory structure.
/org/apache/xyz/MyClass.class
will be
import org.apache.xyz.MyClass;
Upvotes: 3