导入 rt.jar 给我 dalvik 错误
我在项目中使用 import javax.swing.JOptionPane
,并且需要 rt.jar,因为 rt.jar 包含 javax.swing
。但 rt.jar 是一个运行时 jar,我无法添加它,因为添加它会在编译项目时出现 dalvik 错误。
那么有没有其他方法可以解决这个问题或从任何其他 jar 获取 javax.swing ?
I am using import javax.swing.JOptionPane
in my project and I need rt.jar for that since rt.jar contains javax.swing
. But rt.jar is a runtime jar and I cannot add it because adding it gives me a dalvik error when I compile my project.
So is there any other way to solve this or get javax.swing
from any other jar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Dalvik 不运行未修改的 Java 类。 Dalvik 不是 Java!
即使确实如此,Swing(或更准确地说,底层 AWT)也有需要 JVM 支持的本机组件。
即使这不是问题,
rt.jar
中的类也是构成 Java 平台实现的类。您不能只是将一个 JVM 的rt.jar
替换为另一个 JVM 的rt.jar
。它们与 JVM 实现紧密耦合。Dalvik doesn't run un-modified Java classes. Dalvik is not Java!
And even if it did, Swing (or more precisely, the underlying AWT) has native components that need support from the JVM.
And even if that were not a problem, the classes in
rt.jar
are the classes that make up the Java platform implementation. You can't just swap out thert.jar
of one JVM with that of another one. They are tightly coupled with the JVM implementation.您打算如何运行您的项目?通过 IDE(例如 Eclipse)或命令行?如果您通过命令行进行操作并且需要 rt.jar 进行编译,那么您的安装就完成了!
如果您使用的是 Eclipse,则需要将 Java 系统库添加到项目的构建路径中。
How are you trying to run your project? Through an IDE such as Eclipse or command line? If you're doing through command line and need rt.jar to compile, your installation is toast!
If you're using Eclipse, you need to add a Java System Library to your project's build path.