一:打包工具html
在網上下載一個 Inno steup的製做exe文件工具java
下面是我整理好的compile.iss文件(如下這個能夠直接複製過去把要改的東西改掉就能夠直接用了):mysql
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!sql
#define MyAppName "xxxx管理系統" <------軟件的名稱
#define MyAppVersion "V1.0" <-------軟件的版本
#define MyAppPublisher "xxxxxx信息科技有限公司" <------公司名稱
#define MyAppURL "http://www.xxxx.com/" <------公司網址express
[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={{DCCFE898-2E2D-4C7B-9A45-C81B3A50F80C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=D:\soft <------默認安裝的路徑
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
SetupIconFile=C:\Users\g5000\Desktop\soft\logo.ico <------安裝圖標的路徑
Compression=lzma
SolidCompression=yes
PrivilegesRequired=adminapache
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"bootstrap
[Files] <------須要打包成exe文件的jdk+Tomcat+mysql文件的路徑
Source: "C:\Users\g5000\Desktop\soft\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system filestomcat
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\xxxxxx理系統"; Filename: http://localhost:9080 <------ tomcat訪問的端口,這裏改爲9080是爲了不衝突app
[Run] <------ 一鍵安裝後要運行一下三個bat文件,Flags: runhidden;表示運行是隱藏的
Filename: "{app}\tomcat6\Set_Env.bat"; Flags: runhidden;
Filename: "{app}\tomcat6\bin\啓動服務.bat"; Flags: runhidden;
Filename: "{app}\MySQL\bin\啓動服務.bat"; Flags: runhidden;less
二:jdk+Tomcat+mysql具體的修改和整理
1:三個文件目錄:
mysql:
tomcat6:
jdk(jdk放在tomcat的bin目錄下):
2:須要修改或建立的文件
mysql的my.ini文件:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
character_set_server=utf8
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
port = 3307
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
port=3307
default-character-set=utf8
[mysql]
default-character-set=utf8
啓動服務.bat文件:
cd /d %~dp0
"%cd%\mysqld.exe" -install HQmysql
net start HQmysql
tomcat6的Set_Env.bat文件(jdk,配置環境變量並寫到註冊表裏去):
@echo off
echo
cd ..
echo "%~dp0"
echo "%cd%"
set jdkpath=%cd%\tomcat6\bin\Java\jdk1.6.0_45
echo %jdkpath%
setx JAVA_HOME "%jdkpath%" -m
setx CLASSPATH ".;%%JAVA_HOME%%\lib\tools.jar;%%JAVA_HOME%%\lib\dt.jar" -m
echo %Path%
echo %Path%|find /i "%java_home%" && set IsNull=true || set IsNull=false
echo %IsNull%
if not %IsNull%==true (
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_SZ /d "%Path%;%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin" /f
setx Path "%%JAVA_HOME%%\bin;%Path%"
)
exit
tomcat啓動服務.bat文件:
echo
call "%~dp0%service.bat" install tomcat6
echo
sc config tomcat6 start= auto
sc start tomcat6
rem 下面兩句是設置到服務裏自動啓動的
wmic service where name="tomcat6" changestartmode "automatic"
wmic service where name="tomcat6" startservice
exit
下面重點說下tomcat的service.bat文件,由於這個文件要配置tomcat6w.exe文件的java裏的jvm
,若是不配置好服務裏的tomcat是沒法啓動的,啓動就會報。並且tomcat6w.exe也打不開,會出現這個錯誤。因此service.bat文件很重要,下面給出我修改的service.bat,能夠把這個複製下去後用beyond compare這個工具和原來tomcat裏的service.bat文件比較下就能夠清楚的看到我修改的東西。若是想弄清楚service.bat文件里語句的走向流程的話能夠在開始的時候把@echo off改爲@echo on而後在結尾的地方加暫停(pause),而後保存下,雙擊運行,就會彈出
而後把這裏面的語句和service.bat裏的語句進行對比就會明白service里語句是怎麼運行的,以及它的做用。
service.bat配置以下:
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install Install the service using Tomcat6 as service name.
rem Service is installed using default settings.
rem remove Remove the service from the System.
rem
rem name (optional) If the second argument is present it is considered
rem to be new service name
rem ---------------------------------------------------------------------------
setlocal
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
rem if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%cd%"
if exist "%CATALINA_HOME%\bin\tomcat6.exe" goto okHome
rem CD to the upper dir
cd ..
set "CATALINA_HOME=%cd%"
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat6.exe" goto okHome
echo The tomcat6.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
:okHome
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo Service will try to guess them from the registry.
goto okJavaHome
:gotJreHome
if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome
goto okJavaHome
:gotJdkHome
set "JRE_HOME=%JAVA_HOME%\jre"
if not exist "%JAVA_HOME%\jre\bin\java.exe" goto okJavaHome
if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
if not "%JRE_HOME%" == "" goto okJavaHome
set "JRE_HOME=%JAVA_HOME%\jre"
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK not a JRE
goto end
:okJavaHome
if not "%CATALINA_BASE%" == "" goto gotBase
set "CATALINA_BASE=%CATALINA_HOME%"
:gotBase
set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat6.exe"
rem Set default Service name
set SERVICE_NAME=Tomcat6
set DISPLAYNAME=HQTomcat6
if "x%1x" == "xx" goto doInstall
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
set SERVICE_NAME=%1
set DISPLAYNAME=HQTomcat6 %1
shift
if "x%1x" == "xx" goto checkServiceCmd
echo Unknown parameter "%1"
goto displayUsage
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter "%SERVICE_CMD%"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name]
goto end
:doRemove
rem Remove the service
echo Removing the service '%SERVICE_NAME%' ...
echo Using CATALINA_BASE: "%CATALINA_BASE%"
"%EXECUTABLE%" //DS//%SERVICE_NAME% ^
--LogPath "%CATALINA_BASE%\logs"
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
goto end
:removed
echo The service '%SERVICE_NAME%' has been removed
goto end
:doInstall
set "JRE_HOME=%JAVA_HOME%\jre"
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME: "%CATALINA_HOME%"
echo Using CATALINA_BASE: "%CATALINA_BASE%"
echo Using JAVA_HOME: "%JAVA_HOME%"
echo Using JRE_HOME: "%JRE_HOME%"
rem Try to use the server jvm
rem set "JVM=%JRE_HOME%\bin\server\jvm.dll"
rem if exist "%JVM%" goto foundJvm
rem Try to use the client jvm
set "JVM=%JRE_HOME%\bin\client\jvm.dll"
if exist "%JVM%" goto foundJvm
echo Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME.
set JVM="%JAVA_HOME%\jre\bin\client\jvm.dll"
:foundJvm
echo Using JVM: "%JVM%"
set "CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar"
if not "%CATALINA_HOME%" == "%CATALINA_BASE%" set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"
"%EXECUTABLE%" //IS//%SERVICE_NAME% ^
--Description "Apache Tomcat 6.0.45 Server - http://tomcat.apache.org/" ^
--DisplayName "%DISPLAYNAME%" ^
--Install "%EXECUTABLE%" ^
--LogPath "%CATALINA_BASE%\logs" ^
--StdOutput auto ^
--StdError auto ^
--Classpath "%CLASSPATH%" ^
--Jvm "%CATALINA_HOME%\bin\Java\jdk1.6.0_45\jre\bin\client\jvm.dll" ^
--StartMode jvm ^
--StopMode jvm ^
--StartPath "%CATALINA_HOME%" ^
--StopPath "%CATALINA_HOME%" ^
--StartClass org.apache.catalina.startup.Bootstrap ^
--StopClass org.apache.catalina.startup.Bootstrap ^
--StartParams start ^
--StopParams stop ^
--JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" ^
--JvmMs 128 ^
--JvmMx 256
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
echo The service '%SERVICE_NAME%' has been installed.
:end
cd "%CURRENT_DIR%"
主要的東西都在這裏,而後還有tomcat端口的配置我在這裏就不說了。參考博客: