将.class文件添加到NetBeans中的项目 [英] Add a .class file to a project in NetBeans
问题描述
我们的教授提供了一个我们应该在程序中使用的.class文件(Out.class).当我在NetBeans中创建一个新项目时,我应该在哪个目录中复制该文件和/或如何将其导入"到我的项目中,以便可以像 Out.methodwhatever(var);一样使用它.代码>?
Our professor provided a .class file (Out.class) we should use in our Programm. When I create a new project in NetBeans, in what directory am I supposed to copy that file and/or how do I "import" it to my project so I can use it like Out.methodwhatever(var);
?
我已经搜索了这个问题,但我发现人们有一个.jar文件,但我有一个.class文件的情况.
I have already searched for that problem, but I just found cases where people have a .jar file, but I have a .class file.
推荐答案
将 Out.class
复制到某个目录中(不是您的源文件夹).确保复制该类的包结构,例如如果该类实际上是 com.foobar.Out
,则需要将其放入例如 libs/com/foobar
Copy the Out.class
into some directory (not your source folder). Make sure you replicate the package structure of that class, e.g. if that class is actually com.foobar.Out
you need to put it into e.g. libs/com/foobar
右键单击NetBeans中的项目,选择库"类别,然后单击添加JAR/文件夹".选择例如上例中的 libs
文件夹.
The right click on your project in NetBeans, select the "Libraries" category, and click on the "Add JAR/Folder". The select the e.g. the libs
folder from the above example.
这篇关于将.class文件添加到NetBeans中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!