开发者

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.

Importing classes inside JAR files that are in the default package

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

  1. 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.

  2. 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜