正如MadProgrammer所說,您可以在-post-jar
目標上編輯您的build.xml
。爲此,請參閱this鏈接,this鏈接和this問題。
如果您還必須包含庫,請嘗試一個簡單的DOS腳本。照常使用NetBeans構建Java項目,然後在NetBeans項目目錄中創建一個名爲'NewDist'的目錄,並創建一個名爲JarMaker.bat的文件。這是腳本。
@echo off
echo * -------------------------------------------------------- *
echo * - JarMaker V 2.0.0 - For Netbeans Projects - *
echo * -------------------------------------------------------- *
echo 1) Creating Temporary Directory
mkdir classes
echo 2) Copying Library Jars
xcopy /s /y ..\dist\lib\*.jar classes >> nul
cd classes
echo 3) Deflating Library Jars (this may take a while)
for /f %%a IN ('dir /b *.jar') do jar xf %%a >> nul
del *.jar >> nul
cd ..
echo 4) Deflating Main Program Jar
xcopy /y ..\dist\*.jar classes >> nul
cd classes
for /f %%a IN ('dir /b *.jar') do jar xf %%a >> nul
del *.jar >> nul
echo 5) Creating Unique Jar (this may take a while)
jar cvfm ../dist.jar META-INF/manifest.mf ./ >> nul
for /f %%a IN ('dir /b ..\..\dist\*.jar') do ren ..\dist.jar %%a >> nul
cd ..
echo 6) Removing Temporary Files
rmdir /s /q classes >> nul
echo * -------------------------------------------------------- *
echo * - JarMaker V 2.0.0 - Process Complete - *
echo * -------------------------------------------------------- *
Source
相反,如果你想包括圖像,take a look at this question。
兩種方式。您可以在'-post-jar'目標上修改'build.xml',或者您可以將該文件保存爲捆綁資源(在jar中)。 – MadProgrammer
jar是zips,順便說一句。壓縮一個罐子沒什麼用處。 – scottb
如何執行前者?我從來沒有擺弄過build.xml,也不知道從哪裏開始。 – user2467047