如何在没有包数据的情况下编译 .java 文件?
我正在尝试将 .java 文件编译为 .class 文件,以便我可以将其用作在运行时从不同包/程序加载的第三方类。然而,我遇到了包数据的问题,并且收到了 NoClassDefFoundError 错误。有什么办法可以解决这个问题吗?
I'm trying to compile a .java file into a .class file so I can use it as a 3rd party class that I load during runtime from a different package/program. I've run into the problem however of having package data and I get a NoClassDefFoundError. Is there a way I can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,从我读到的内容中,我了解到您想要单独编译您的一个类和另一个程序,然后能够在运行时以某种方式合并它们。据我所知这是不可能的。您必须将这个特定的 .java 文件与您正在讨论的程序一起编译。您还必须在要使用您的类的程序的 .java 文件中使用 import 语句。
So from what I read I got that you want to separately compile a class of yours and and another program and then be able to merge them in some way during runtime. As far as I know that is not possible. You will have to compile this specific .java file alongside the program you are talking about. You will have to make use of the import statement as well in the .java files of the program that are going to use your class.