2011-03-13 49 views

回答

15

類文件的JAR文件

用法:罐子{ctxu} [vfm0M] [JAR文件]

[清單文件] [-C DIR]文件...

選項:

-c create new archive 

-t list table of contents for archive 

-x extract named (or all) files from archive 

-u update existing archive 

-v generate verbose output on standard output 

-f specify archive file name 

-m include manifest information from specified manifest file 

-0 store only; use no ZIP compression 

-M do not create a manifest file for the entries 

-i generate index information for the specified jar files 

-C change to the specified directory and include the following 

文件如果任何文件是目錄則遞歸處理。清單文件名稱和存檔文件名稱需要按照指定的'm'和'f'標誌相同的順序指定 。

實施例1:歸檔2類文件到名爲classes.jar存檔:

`jar cvf classes.jar Foo.class Bar.class` 

實施例2:使用現有的清單文件 'mymanifest' 和歸檔

foo /目錄中的所有文件轉換爲'classes.jar':

jar cvfm classes.jar mymanifest -C foo/ . 

將jar文件轉換爲。exe文件

1)JSmooth .exe wrapper

2)JarToExe 1.8

3)Executor

4)Advanced Installer

Convert .class to .exe is discussed in length here

-1

使用命令行創建jar文件。 http://download.oracle.com/javase/tutorial/deployment/jar/build.html

要exe的類。回答問題http://www.javacoffeebreak.com/faq/faq0042.html

Jar to exe。在http://viralpatel.net/blogs/2009/02/convert-jar-to-exe-executable-jar-file-to-exe-converting.html中回答

將exe轉換爲jar文件是可能的。但是需要進行逆向工程來發現exe文件中的內容,並提取和執行您想要的任何內容。在我看來,根本不值得。

1

要將(實際上是打包的).class文件轉換爲.jar文件,請使用jar tool。然後,您可以使用諸如Launch4j,JSmooth或其他幾個軟件包(在網上搜索「jar exe」)從.jar生成.exe文件。

0

如果您使用的是Netbeans IDE,那麼從.class文件創建.exe文件不會花費太多時間。在IDE中,創建一個新項目並將Java程序放入此項目中。現在按照下列步驟 -

  1. 右鍵單擊項目並選擇屬性。
  2. 從左側面板中選擇運行,然後在右側面板中輸入主要類(定義主要方法)。
  3. 再次右鍵單擊該項目並選擇添加庫。選擇擺動佈局擴展。點擊添加庫。 4.現在從IDE的運行菜單中選擇clean和build。確保你已經將這個項目設置爲主項目。
  4. 打開CMD並將目錄設置爲您的項目。轉到「dist」>並輸入java -jar jarname.jar。
  5. 您的程序現在正在cmd中運行。
  6. 打開launch4j並提供所需的信息。
  7. 運行並享受您的應用程序。