如何在 NetBeans 6.8 中从其他项目导入 java 类?

发布于 2024-08-18 13:45:25 字数 246 浏览 3 评论 0原文

我刚刚开始使用 Java,我真的很喜欢这门语言。我正在使用 NetBeans IDE,但我发现了一个奇怪的疏忽。我可以在项目中创建新类,但 NetBeans 似乎不支持任何将现有类导入项目的方法。

我设法通过转到已经出现所需类的其他项目来完成它,然后将其复制/粘贴到新项目的源代码文件夹中,然后更改粘贴文件顶部的包名称以匹配新项目的包名。

有没有一种很好的直接方法可以从 NetBeans 界面执行此操作?

感谢您对此的任何帮助。

I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.

I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.

Is there a nice direct way to do this from the NetBeans interface?

Thanks for any help on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

腹黑女流氓 2024-08-25 13:45:25

在“项目”窗口中,您可以展开您正在处理的项目。右键单击并选择添加项目...。您将看到一个对话框,允许您选择另一个包含您希望使用的 Java 类的 Netbeans 项目。

In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.

浮华 2024-08-25 13:45:25

您只需制作要在另一个项目中使用的那个/那些 java 文件的 .jar 文件。
右键单击文件->导出->java->.jar 然后完成。

现在您可以将这些 jar 使用到您的另一个项目中。

You have to just make the .jar file of that/those java files which you want to use in another project.
right click on file->export->java->.jar then finish.

Now you can use these jar into your another project.

遗弃M 2024-08-25 13:45:25

当您在 netbeans 中构建 java 项目时,它会在当前项目目录的 dist 文件夹中创建一个 jar 文件。
您可以将此 jar 文件作为包用于其他项目,只需在下一个项目中将其添加为 ADD jar 即可。我已经尝试过此操作,我正在使用我的旧项目 jar 文件进行新项目开发。

When you build the java project in netbeans it creates a jar file on the dist folder in the current project directory.
You can use this jar file for the other project as a package by adding this as ADD jar in the next project.I have tried this ,i am using my old project jar file for new project development.

Hello爱情风 2024-08-25 13:45:25

使用 netbeans 应用程序中的“清理并构建”项目选项,该选项创建您正在查找的“dist”文件夹(显然找不到,因为您还没有清理和构建)

Use the 'Clean and build' your project option from the netbeans application, that creates the 'dist' folder which you are looking for (and obviously can't find because you havn't cleaned&buld)

与他有关 2024-08-25 13:45:25

netbeans 本身会创建 .jar 文件,您可以将 jar 文件添加到您正在处理的当前项目中。

The netbeans itself creates .jar files and you can add the jar file to the current project you are working on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文