且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在NetBeans项目生成的jar文件中的清单文件中设置Main类

更新时间:2023-09-19 12:53:16

我将对提议的解决方案和帮助我的解决方案进行总结!

I'm going to make a summary of the proposed solutions and the one that helped me!

一个阅读此错误报告:
NetBeans 6.8为a创建jar的方式中的错误Java Library Project。

After reading this bug report: bug in the way NetBeans 6.8 creates the jar for a Java Library Project.


  1. 在项目根目录中创建manifest.mf文件

  1. Create a manifest.mf file in my project root

编辑manifest.mf。我看起来像这样:

Edit manifest.mf. Mine looked something like this:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01 (Sun Microsystems Inc.)
Main-Class: com.example.MainClass
Class-Path: lib/lib1.jar lib/lib2.jar


  • 打开文件/nbproject/project.properties

  • Open file /nbproject/project.properties

    添加行

    manifest.file = manifest.mf

    清理+构建项目

    现在.jar已成功构建。

    Now the .jar is successfully build.

    非常感谢 vkraemer