如何在 Netbeans 中创建 Jar 文件 [英] How to create a Jar file in Netbeans
问题描述
好吧,我有使用 IDE netbeans 完成的源代码.现在我想将这个 java 应用程序移动到一个 web 应用程序.为此,我需要从我的源代码创建一个 jar 文件,以便我可以在 ma jsp 文件中调用它.我无法在 netbeans 或任何其他方式中找到任何选项来创建此源代码的 .jar 文件.谁能告诉我怎么做.
Well I have my source code that i have done using the IDE netbeans. Now I wanted to move this java application to a web application. For that I need to create a jar file from my source code, so that I could invoke it in ma jsp file. I have not been able to find any option in netbeans or any other way to create a .jar file of this source code. Could someone tell me how to do that.
谢谢
推荐答案
使用 NetBeans 创建一个 Java 归档 (.jar) 文件,如下所示:
Create a Java archive (.jar) file using NetBeans as follows:
- 右键单击项目名称
- 选择属性
- 点击打包
- 检查编译后构建JAR
- 检查压缩JAR文件
- 点击确定接受更改
- 右键单击项目名称
- 选择构建或清理并构建
Clean and Build 将首先删除构建工件(例如 .class
文件),而 Build 将保留任何现有的 .class
文件,创建必要的新版本.为了说明这一点,请想象一个有两个类 A 和 B 的项目.
Clean and Build will first delete build artifacts (such as .class
files), whereas Build will retain any existing .class
files, creating new versions necessary. To elucidate, imagine a project with two classes, A and B.
第一次构建时,IDE 会创建 A.class
和 B.class
.现在您删除 B.java
但不清除 B.class
.执行 Build 应该将 B.class
留在构建目录中,并将其捆绑到 JAR 中.选择Clean and Build 将删除B.class
.由于B.java
被删除,B.class
将不再被捆绑.
When built the first time, the IDE creates A.class
and B.class
. Now you delete B.java
but don't clear out B.class
. Executing Build should leave B.class
in the build directory, and bundle it into the JAR. Selecting Clean and Build will delete B.class
. Since B.java
was deleted, no longer will B.class
be bundled.
JAR 文件已构建.要在 NetBeans 中查看它:
The JAR file is built. To view it inside NetBeans:
- 点击文件标签
- 展开项目名称>> dist
确保在构建 JAR 文件时不会排除文件.
Ensure files aren't being excluded when building the JAR file.
这篇关于如何在 Netbeans 中创建 Jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!