Web project packaged as EXE in Windows next click Install Jdk+tomcat+mysql

Source: Internet
Author: User
Tags change settings goto dedicated server apache tomcat

Recently, because the company sales personnel do not understand the software, so every deployment project requires technical personnel to the customer site deployment, very inconvenient. So the company let our project into a fool-like installation, so that you can let sales staff to install, but also to the technology province a lot of things. I found a lot of tutorials on the internet but some places are not all, and everyone writes are not the same, so in the production process encountered a lot of problems, after a few days of research finally realized, now put my finishing, research write down, hope can help more people.

One: Packaging tools

Download a inno steup authoring exe file tool on the Web

Here is my Compile.iss file (the following can be copied directly in the past to change the things to get rid of can be used directly):

; Script generated by the Inno Setup Script Wizard.
; See the documentation for DETAILS on CREATING inno SETUP SCRIPT files!

#define MYAPPNAME "XXXX Management system" <------software Name
#define Myappversion version of "V1.0" <-------Software
#define MYAPPPUBLISHER "XXXXXX Information Technology Co., Ltd." <------company Name
#define MYAPPURL "http://www.xxxx.com/"<------Company website

[Setup]
; Note:the value of AppId uniquely identifies this application.
; 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<------The path of the default installation
defaultgroupname={#MyAppName}
Outputbasefilename=setup
Setupiconfile=c:\users\g5000\desktop\soft\logo.ico<------Path to the installation icon
Compression=lzma
Solidcompression=yes
Privilegesrequired=admin


[Languages]
Name: "Chinesesimp"; Messagesfile: "COMPILER:DEFAULT.ISL"

[Files]<------The path to the Jdk+tomcat+mysql file that needs to be packaged as an EXE file
Source: "c:\users\g5000\desktop\soft\*"; DestDir: "{app}"; Flags:ignoreversion Recursesubdirs Createallsubdirs
; Note:don ' t use "flags:ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:uninstallprogram,{#MyAppName}}"; Filename: "{Uninstallexe}"
Name: "{commondesktop}\xxxxxx system"; filename:http://localhost:9080<------Tomcat accesses the port, which is changed here to 9080 to avoid conflicts

[Run] <------One-click installation to run a three bat files,Flags:runhidden; Indicates that the run is hidden
Filename: "{app}\tomcat6\set_env.bat"; Flags:runhidden;
Filename: "{app}\tomcat6\bin\ start service. bat"; Flags:runhidden;
Filename: "{app}\mysql\bin\ start service. bat"; Flags:runhidden;

Second:jdk+tomcat+mysql Specific modification and collation

1: Three Files directory:

Mysql:

TOMCAT6:

JDK (JDK placed in Tomcat's Bin directory):

2: Files that need to be modified or created

MySQL My.ini file:

# for advice The change settings
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# * * * Don't EDIT this FILE. It ' s a template which'll be copied to the
# * * * default location during install, and would 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 all 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 is 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 is 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

start the service. BatFile:

CD/D%~dp0
"%cd%\mysqld.exe"-install hqmysql
net start Hqmysql
"%cd%\mysqladmin"-u root Password root

Tomcat6 the Set_env.bat file (JDK, configure environment variables and write to the registry):

@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 starts the service. bat file:

Echo
Call "%~dp0%service.bat" Install Tomcat6
Echo
sc config tomcat6 start= auto
SC start TOMCAT6
REM The following two sentences are set to start automatically in the service
WMIC service where name= "Tomcat6" ChangeStartMode "Automatic"
WMIC service where name= "Tomcat6" StartService
Exit

The following highlights the Tomcat Service.bat file because this file configures the JVM in Java for the Tomcat6w.exe file

tomcat6w.exe can not open, this error will occur. So the Service.bat file is very important, the following gives me to modify the service.bat, you can copy this down and use beyond Compare this tool and the original Tomcat in the File comparison You can see clearly what I have modified . If you want to find out file in the direction of the flow of the statement can be at the beginning of the @echo off change to @echo on then pause at the end of the , then save, double-click to run, and it will pop up

Then compare the statements in this with the statements in the Service.bat to understand how the service statement works and what it does.

The service.bat configuration is as follows:

@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 under the Apache License, Version 2.0
REM (the "License"); Except in compliance with
REM the License. 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 writing, software
REM distributed under the License is distributed on a "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 the default settings.
REM Remove Remove the service from the System.
Rem
REM name (optional) If The second argument is present it's 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 is not found ...
echo the CATALINA_HOME environment variable is not defined correctly.
echo this environment variable are needed to run
Goto END
: Okhome
REM Make sure prerequisite environment variables is 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 would 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 are needed to run
Echo Nb:java_home should point-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%"
:d Isplayusage
Echo.
echo Usage:service.bat Install/remove [service_name]
Goto END

:d Oremove
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

:d Oinstall
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 is 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%"

The main thing is here, and then there is the configuration of the Tomcat port I won't say it here. Reference blog:

http://blog.csdn.net/liuhaomatou/article/details/52576162

Web project packaged as EXE in Windows next click Install Jdk+tomcat+mysql

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.