Importing classes inside JAR files that are in the default package
How do I use Queue here?
I can't get the import to work because Queue.class is not in a package.
I have tried everything in this universe, and more.
http://i.stack.imgur.com/AFrrc.jpg开发者_StackOverflow社区Your Queue
class is under unnamed package (refer JLS). It can't be imported. Also, it's bad practice.
You have two options
Move your own code to unnamed package. Theoretically, both of them being in same package, you will not need to import
Queue
as it's class-name is suffice to find out the class.Use JarJar - a tool to repackage your Jar files. Repackage the Jar containing the
Queue
class and move the unnamed package to a sensible package name. Use Fully Qualified Class Name (FQCN) to import.
I would suggest to use packages and go for option 2.
Edit 1: also see this What's the syntax to import a class in a default package in Java?
精彩评论