如何在没有包数据的情况下编译.java文件?

时间:2021-10-15 14:22:50

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?

我正在尝试将.java文件编译为.class文件,因此我可以将其用作第三方类,我在运行时从另一个程序包/程序加载。我遇到了问题,但是有了包数据,我得到了一个N​​oClassDefFoundError。有没有办法解决这个问题?

1 个解决方案

#1


0  

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.

因此,根据我的内容,我得到了你想要单独编译你的一个类和另一个程序,然后能够在运行时以某种方式合并它们。据我所知,这是不可能的。您将不得不将这个特定的.java文件与您正在讨论的程序一起编译。您将不得不在将要使用您的类的程序的.java文件中使用import语句。

#1


0  

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.

因此,根据我的内容,我得到了你想要单独编译你的一个类和另一个程序,然后能够在运行时以某种方式合并它们。据我所知,这是不可能的。您将不得不将这个特定的.java文件与您正在讨论的程序一起编译。您将不得不在将要使用您的类的程序的.java文件中使用import语句。