打包可执行jar包时,MANIFEST.MF总是个让人头疼的东西,经常出现这种那种问题。
一个例子:
================================================================================
Manifest-Version: 1.0
Main-Class: test.Main
Class-Path: ./ ./lib/commons-collections-3.2.jar ./lib/commons-dbcp-1.2.2.jar
./lib/commons-lang-2.3.jar ./lib/commons-logging-1.1.jar
================================================================================
各部分解释:
Manifest-Version MF文件版本号
Main-Class 包含main方法的类
Class-Path 执行这个jar包时的ClassPath
以下是需要注意的各个要点:
1. Manifest-Version、Main-Class和Class-Path后面跟着一个英文的冒号,冒号后面必须跟着一个空格,然后才是版本号、类和ClassPath。
2. Class-Path中的各项应使用空格分隔,不是逗号或分号。
3. Class-Path中如果有很多项,写成一行打包的时候会报错line too long,这时需要把Class-Path分多行写。注意:从第二行开始,必须以两个空格开头,三个以上我没试过,不过不用空格开头和一个空格开头都是不行的,我已经试过了。
4. Class-Path写完之后最后一定要有一个空行。
5. jar包内有些配置文件想放在jar包外面,比如文件config.properties:如果这个文件是以路径方式载入的,比如new file("./config/config.properties"),那么将config.properties放在jar包相同目录下的config目录下即可,也就是说“./”路径等价于jar包所在目录;如果这个文件是以ClassPath下的文件这种方式载入的,比如在Spring中载入classpath:config.properties,则在MF文件的配置文件的ClassPath中添加“./”,然后将这个配置文件与jar包放在同一个目录即可,当然也可以在MF文件的配置文件的ClassPath中添加“./config/”,然后把配置文件都放在jar包相同目录下的config目录下。
详细解决方案
可执行jar包 manifest.mf
热度:16 发布时间:2023-12-12 08:56:23.0
相关解决方案
- 发布dll,访问提示异常The located assembly's manifest definition with name 'Copy of TCL" does not match the assembly reference
- 异常"Unable to find manifest signing certificate in the certificat.
- JAVA1.8下 Applet出现异常:Missing Permissions manifest attribute in main jar
- META-INF/MANIFEST.MF does not exist 小弟我该怎么处理
- MANIFEST.MF文件的国际化不解
- eclipse manifest editor插件解决方案
- 用eclipse打包成的.jar文件运行起来结果是Failed to load Main-Class manifest attribute from 文件名解决方案
- Android API Guides-App Manifest
- Android API Guides-App Manifest <supports-screens> <uses-configuration>
- Android API Guides-App Manifest <uses-feature>
- Android API Guides-App Manifest <uses-sdk> <uses-permission>
- Duplicate name in Manifest (程序打包运行提示警告),该如何处理
- MANIFEST.MF 是干什么用的? 通过eclipse 打包需要注意什么?该怎么处理
- AndroidStudio1.4 manifest 中注册Activity时的异常提示解决方法
- manifest 怎么绑定多个类
- Android开发-身高体重指数(BIM)计算-定义Android列表(Manifest)并平添新活动(Activity)
- android系列:第二篇android组件、manifest.xml、存储方式、通信方式概述
- Android-ManiFest
- 可执行jar包 manifest.mf
- andorid Manifest entries (Manifest属性)
- MANIFEST.MF文件格式详解
- no main manifest attribute,找不到main函数
- MANIFEST.MF文件的格式
- 使用aspectjweaver时报“agent library failed to init: instrument”“Error opening zip file or JAR manifest m
- general error c101008a: Failed to save the updated manifest to the file .\D
- Manifest merger failed with multiple errors, see ?
- Android Manifest 详解
- Manifest merge failed with multiple errors的解决之道
- Manifest.xml中的package中的userId属性和组件中的process属性的关系
- IntelliJ IDEA打jar时,MANIFEST.MF内容出错