如何在Netbeans中创建Jar文件 [英] How to create a Jar file in Netbeans

查看:114
本文介绍了如何在Netbeans中创建Jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我使用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:


  1. 右键单击项目名称

  2. 选择属性

  3. 点击打包

  4. 检查编译后构建JAR

  5. 检查压缩JAR文件

  6. 点击确定接受更改

  7. 右键点击项目名称

  8. 选择构建清理并构建

  1. Right-click on the Project name
  2. Select Properties
  3. Click Packaging
  4. Check Build JAR after Compiling
  5. Check Compress JAR File
  6. Click OK to accept changes
  7. Right-click on a Project name
  8. 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:


  1. 点击文件标签

  2. 展开项目名称>> dist

  1. Click the Files tab
  2. Expand Project name >> dist

确保在构建JAR文件时不排除文件。

Ensure files aren't being excluded when building the JAR file.

这篇关于如何在Netbeans中创建Jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆