天天看點

Eclipse導出Jar包 和 MANIFEST.MF檔案

  Eclipse 導出Jar包,在工程中File-Export-JAR file-Next...-Finish,注意選擇自己的程式Main Class,其中Jar包中的MANIFEST.MF檔案包含了jar的主程式入口和依賴jar的存放位置等資訊。

Eclipse導出Jar包 和 MANIFEST.MF檔案

Java -jar  Test.jar      

導出Jar包後,如有外部包依賴,還要修改Jar包中的 MANIFEST.MF 檔案

Manifest-Version: 1.0
Main-Class: modification.AppFrame
Class-Path: lib/classes12.jar
Manifest-Version   為版本資訊
Class-Path         當程式有外部包依賴時,可在目前目錄下建立lib目錄,放入依賴的jar包
Main-Class         主程式入口缺少這個屬性,程式會找不到Main入口
Failed to load Main-Class manifest attribute from  Test.jar      

Windows下可以直接用WinRar工具編輯Test.jar中META-INF\MANIFEST.MF檔案

Eclipse導出Jar包 和 MANIFEST.MF檔案

繼續閱讀