(1) create a Windows exe program
The exe program or service program made of Windows by Java is really full and abnormal, but if you don't remember the background program on a server, which of the following idiots accidentally shut down, or if someone kills the Java in the process, it is necessary to follow the method I mentioned below:
Borland is not a public usage technique. It can use JBuilder to create EXE files to start java files. JBuilder does not support local compilation. However, there is a hidden technique that allows you to start a Java program from an executable file, which can appear or does not appear in the console window. To do this, you need these files in the bin directory of JBuilder:
Jbuilder.exe (with DOS window)
Jbuilderw.exe (without DOS window)
JBuilder. config
JDK. config
Container, but the console window is not displayed during running. The key to using these files is the file name. “Jbuilder.exe "searches for a configuration file named" JBuilder. config ", which contains the required information for running Java programs. In the same example, jbuildercmdexe‑ jbuilder.exe "is used to start Java programs without the console window.
Hosts file.
Therefore, you only need to rename JBuilder .exe, jbuilerw.exe, and JBuilder. config to the corresponding file name, and specify the master
Class and category, you can start Java applications by executing jbuilder.exe (or the renamed EXE file.
Set "javapath" in JDK. conifg, for example: "javapath ../jdk1.5/JRE/bin/client/JVM. dll"
Set smsdialtest. config:
# + ----------------------------------------------------- +
# |
# | This is the configuration file for the smsdialtest |
# |
# | Do not make modifications without maintaining a |
# | Backup copy. See config_readme.html for a |
# | Description of the recognized ctictives. |
# |
# + ----------------------------------------------------- +
# Read the shared JDK Definition
Include JDK. config
# Tune this VM to provide enough headroom to work on large
# Applications
Vmparam-xms128m
Vmparam-xmx512m
# Put the light AWT wrapper and various JDK fixes on the boot path
Addbootpath ../Image
# Add all jar files located in the patch, lib and LIB/EXT directory
Addjars ../lib
Addjars ../classes
# Activate the shell Integration
Socket 8888
# Add all the configuration files located in the LIB/EXT directory
# JBuilder needs to have access to the environment
Exportenv
# Start smsdialtest using the main class
Mainclass smsdialtest. Gui. smsdialtestmainframe
(2) make Java programs into Windows service programs
I tried to make Java into an EXE and then make it into a Windows service, but the problem came out. There is no place to set the environment variables and many parameters.
Finally, we use "Java service wrapper" to solve this problem.
Wrapper Download Page
Http://sourceforge.net/project/showfiles.php? Group_id = 39428
The latest version 3.1.2 is used in this version.
Environment: win2003server + jdk1.5 + wrapper3.1.2
Configure the wrapper. conf file>
#*************************************** *****************************
# Wrapper Properties
#*************************************** *****************************
# Java application
Wrapper. java. Command = E:/project/developide/project/unicomsms/dialtest/jdk1.5/bin/Java
# Java main class. This class must implement the wrapperlistener Interface
# Or guarantee that the wrappermanager class is initialized. helper
# Classes are provided to do this for you. See the Integration Section
# Of the documentation for details.
Wrapper. java. mainclass = org. tanukisoftware. wrapper. wrappersimpleapp
# Java classpath (include wrapper. Jar) add class path elements
# Needed starting from 1
Wrapper. java. classpath.1 = % PATH %
Wrapper. java. classpath.2 = ../lib/wrapper. Jar
Wrapper. java. classpath.3 = ../lib/*. Jar
Wrapper. java. classpath.4 = ../classes
Wrapper. java. classpath.5 = ../Conf
Wrapper. java. classpath.6 = ../log
# Java library path (location of wrapper. dll or libwrapper. So)
Wrapper. java. Library. path.1 = ../lib
Wrapper. java. Library. path.2 = ../jdk1.5/JRE/lib/EXT/win32com. dll
Wrapper. java. Library. path.3 = ../jdk1.5/JRE/bin/win32com. dll
# Java additional parameters
# Wrapper. java. additional.1 =
# Initial Java heap size (in MB)
# Wrapper. java. initmemory = 128
# Maximum Java heap size (in MB)
# Wrapper. java. maxmemory = 512
# Application parameters. Add parameters as needed starting from 1
Wrapper. App. parameter.1 = smsdialtest. util. smsserverutil
#*************************************** *****************************
# Wrapper logging Properties
#*************************************** *****************************
# Format of output for the console. (See docs for formats)
Wrapper. Console. format = PM
# Log level for console output. (See docs for log levels)
Wrapper. Console. loglevel = info
# Log file to use for wrapper output logging.
Wrapper. logfile = ../log/wrapper. Log
# Format of output for the log file. (See docs for formats)
Wrapper. logfile. format = lptdm
# Log level for log file output. (See docs for log levels)
Wrapper. logfile. loglevel = info
# Maximum size that the log file will be allowed to grow to before
# The log is rolled. size is specified in bytes. The default value
# Of 0, disables log rolling. May abbreviate with the 'K' (Kb) or
# 'M' (MB) Suffix. For example: 10 m = 10 megabytes.
Wrapper. logfile. maxsize = 0
# Maximum number of rolled log files which will be allowed before old
# Files are deleted. The default value of 0 implies no limit.
Wrapper. logfile. maxfiles = 0
# Log level for sys/event log output. (See docs for log levels)
Wrapper. syslog. loglevel = none
#*************************************** *****************************
# Wrapper windows Properties
#*************************************** *****************************
# Title to use when running as a console
Wrapper. Console. Title = value-added service integrated network management service Dial Test client software
#*************************************** *****************************
# Wrapper Windows NT/2000/XP Service Properties
#*************************************** *****************************
# Warning-do not modify any of these properties when an application
# Using this configuration file has been installed as a service.
# Please uninstall the service before modifying this section.
# Service can then be reinstalled.
# Name of the service
Wrapper. ntservice. Name = service name
# Display name of the service
Wrapper. ntservice. displayname = service name
# Description of the service
Wrapper. ntservice. Description = service name
# Service dependencies. Add dependencies as needed starting from 1
Wrapper. ntservice. dependency.1 =
# Mode in which the service is installed. auto_start or demand_start
Wrapper. ntservice. starttype = auto_start
# Allow the Service to interact with the desktop.
Wrapper. ntservice. Interactive = false
Copy several files under the wrapper-windows-x86-32-3.2.1/src/bin directory to your bin directory and change their. bat. In extension to. bat.
App. bat. In // manually start your program with a DOS window. At first, you need to use this file to test whether your environment has been set up.
InstallApp-NT.bat.in // install the service program. After successful installation, your service program will be displayed in the Windows Service
UninstallApp-NT.bat.in // uninstall the service program.
Wrapper.exe // wrapper main program
Copy wrapper. dll and wrapper. jar2 files under the wrapper-windows-x86-32-3.2.1/lib directory to your lib directory.
Finally, you first use app. BAT to test your program. If everything is normal, run the InstallApp-NT.bat .. The service is successfully created.