如何在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.
谢谢
推荐答案
创建Java档案(.jar)文件使用NetBeans如下:
Create a Java archive (.jar) file using NetBeans as follows:
- 右键单击项目名称
- 选择属性
- 点击打包
- 检查编译后构建JAR
- 检查压缩JAR文件
- 点击确定接受更改
- 右键点击项目名称
- 选择构建或清理并构建
- Right-click on the Project name
- Select Properties
- Click Packaging
- Check Build JAR after Compiling
- Check Compress JAR File
- Click OK to accept changes
- Right-click on a Project name
- Select Build or Clean and Build
清理和构建将首先删除构建工件(例如 .class
文件),而构建将保留任何现有的 .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
。执行构建应在构建目录中保留 B.class
,并将其捆绑到JAR中。选择清理并生成将删除 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
- Click the Files tab
- Expand Project name >> dist
确保在构建JAR文件时不排除文件。
Ensure files aren't being excluded when building the JAR file.
这篇关于如何在Netbeans中创建Jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!