Try   HackMD

Eclipse | export / clean up Launch configuration

tags: Java Runnable Jar clean up Configaration

XX飛機於X月X日墜毀於XX洋距深度打撈約為1000多公尺處,確切偵獲黑盒子信號

類似事件偶而在新聞上播出,重上述中可以發現,每次墜毀事件皆要求要打撈出黑盒子
而在程式開發人員心中, Jar包地位 == 黑盒子重要性 (極為重要)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
認識 Jar 包

Jar包全名為 Java Archive File,顧名思義就是與java有關且可多個文件合而為一呈現

而Jar包與zip包相似,唯一不同點在於Jar包內包含了一個 META-INF/MANIFEST.MF 文件

其 MANIFEST.MF文件內含重要Class-Path/Main-Class,決定了這個jar包主要執行的main程式


Ⅰ. IDE - Jar打包

以下是由Eclipse IDE進行打包

A ) 執行Eclipse IDE,並對需要包裝的主程式<專案> Export產出

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 
 
B )選取 Java/Runnable JAR file

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 
 
C )選擇需求的 Launch configuration / Export destination

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
重點: 需打包的code必須compiler,才會在Launch configuration出現

      而有改動的code也必須compiler,不然在Launch configuration中出現為未更動狀態

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

E ) 最後選擇包裝方式 Library handling

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Library handling 分成以下三種:

  • Extract required libraries into generated JAR
    將使用的 library / Jar包 一同包裝在Jar檔,但存取的部分只有.class檔包裝在內
  • Package required libraries into generated JAR
    將使用的 library / Jar包 一同包裝成Jar檔,與Extract 功能不同的地方為
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    Package是將整使用到的Jar包打包,而非.class檔存取
  • Copy required libraries into a sub-folder next to the generated JAR
    如字面意思,提取程式需要的library / Jar包,另外用sub-folder區隔並放在同路徑下
    而運行的Jar包內僅含有 .class 的應用文件
    .

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
缺點檢討

第一、二項:當應用程式更新,則用戶就必須下載全新安裝檔以更新數據
  第三項:因為是Jar檔與library分開包裝,用戶只要下載更新的程式代碼

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
選項2 可以將所有內容整齊地打包成單個Jar,並將引用的 Jar檔 與.class文件分開(較推薦)


Ⅱ. 清理 Launch Configuration

當Compiler過多後,Launch configuration會產生過多"無用"的程式檔

必要時須清理Lauch configuration的檔案,以避免混亂
 
A ) 進到Lauch configuration存放位置
   路徑為

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
eclipse-work > .metadata > .plugins > org.eclipse.debug.core > .launches

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 
B ) 清空.launches所有包含物 <即代表清空Launch configurattion>

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

參考網站 連結
Eclipse: How to Clean Up Launch Configurations
What is the difference between runnable jar library handling options?