一键安装web项目
所需软件:
Inno setup
Exe4j
Bat to exe
Inno setup 脚本
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName ""
#define MyAppVersion "1.5"
#define MyAppPublisher ", Inc."
#define MyAppURL "http://www.example.com/"
[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={{C3D5CDC2-0590-4C2F-8A80-0AE3F67D71DA}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
SetupLogging=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
[Icons]
Name: "{group}\{#MyAppName}";Filename: "{app}\index.exe";
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\index.exe";
[Files]
Source: "C:\Users\admin\Desktop\packages\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Run]
Filename: "{app}\server\bin\install_service.exe";
Filename: "{app}\server\bin\start_service.exe";
[UninstallRun]
Filename: "{app}\server\bin\shutdown_service.exe";
Filename: "{app}\server\bin\uninstall_service.exe";
启动关键代码
if (java.awt.Desktop.isDesktopSupported()) {
try {
// 创建一个URI实例
java.net.URI uri = java.net.URI.create("http://localhost:8081/web");
// 获取当前系统桌面扩展
java.awt.Desktop dp = java.awt.Desktop.getDesktop();
// 判断系统桌面是否支持要执行的功能
if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {
// 获取系统默认浏览器打开链接
dp.browse(uri);
}
} catch (Exception e) {
e.printStackTrace();
}
}
将java打成jar 转成exe,或者直接bat脚本转exe
将JAVA_HOME配置环境变量
bat脚本内容就是注册服务 启动服务 关闭服务 卸载服务
有关数据库的不在此讨论,有关精简jre不在此讨论。