下來,打開命令提示符,然后定位到項目的根目錄。執(zhí)行以下命令將應(yīng)用程序及其依賴項打包到 “package” 文件夾中:

“`

javapackager -createjar -appclass

-srcdir out/production/ -srcfiles .jar -outdir package -outfile

“`

將 `

`、“和“替換為你的主類名稱、項目名稱和輸出JAR文件名稱。如果上述操作成功,你應(yīng)該在 “package” 文件夾中看到打包好的JAR文件。

**4. 創(chuàng)建Inno Setup腳本**

為了將包含JavaFX應(yīng)用程序的JAR文件打包成Windows可執(zhí)行文件,需要為Inno Setup編寫一個簡短的腳本。在項目根目錄下,創(chuàng)建名為 “inno_setup_script.iss” 的文件,并寫入以下內(nèi)容:

“`

; Script generated by the Inno Setup Script Wizard.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]

; NOTE: The value of AppId uniquely identifies this application.

; Do not use the same AppId value in installers for other applications.

; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)

AppId={{GUID}}

AppName=

AppVersion=1.0

;AppVerName= 1.0

AppPublisher=

DefaultDirName={pf}\JavaFX

DisableProgramGroupPage=truvs2010咋制作exe程序e

DefaultGroupName=

Timing=true

;DisableStartupPrompt=true

OutputDir=package

OutputBaseFilename=_setup

Compression=lzma

SolidCompression=yes

WizardStyle=modern

;PrivilegesRequiredpython生成的exe安裝包=admin

[Languages]

Name: “english”; MessagesFile: “compiler:Default.isl”

[Tasks]

;Name: “desktopicon”; Description: “{cm:CreateDesktopIcon}”; GroupDescription: “{cm:AdditionalIcons}”; Flags: unchecked

; Uncomment the following line to get an uncompressed JRE installed, rather than the lzma compressed one provided as-is

; Name: “with_java”; Description: “Install bundled JRE (~160MB)”; GroupDescription: “Additional Tasks”; Flags: unchecked

[Files]

Source: “package\.jar”; DestDir: “{app}”; Flags: ignoreversionrecursesubdirscreateallsubdirsexcludesubdirfiles;

未經(jīng)允許不得轉(zhuǎn)載:智電網(wǎng)絡(luò) NET » ideajavafx打包exe過程介紹

相關(guān)推薦