Java Service Wrapper from source
To launch any Java program as a service, you might have to use a wrapper. This article shows how to build a current release of the Tanuki Service Wrapper (x64) from source. Tanuki Software provides three versions of the Java Service wrapper:
- Professional Edition (paid)
- Standard Edition (paid)
- Community Edition (free)
The paid versions of the wrapper require the configuration file to contain a machine-specific license key in order to function. When you use any x64 version of Windows as your host system, you are forced to either buy licenses or build the Wrapper from source, since they do not provide the binaries for the Community Edition. So here, we are going to build the Community Edition from source.
Update: I added a compiled version for Windows x64 in another post
Newer versions: Newer versions of the wrapper are available here.
Prerequisites
In order to build the wrapper, you require the following software:
- Windows 64-bit Operating System (e.g. Windows Server 2003 x64)
- Microsoft Visual Studio 2005 (upgraded to VS2008 in 2013)
- Microsoft Platform SDK for Windows Server 2003 R2
- Sun Java JDK
- Apache Ant
Install Visual Studio 2005 & Platform SDK
On your 64-bit Operating System, install Visual Studio 2005. While installing, modify the installation path to the following value:
C:\Program Files\Microsoft Visual Studio 8
This ensures that you can use the provided build packages from Tanuki Software without any modification of the ANT file.
After the installation of Visual Studio, install the downloaded platform SDK (link provided above).
JDK & ANT
Download the JDK from the Sun website (link provided above) and install it anywhere on your machine (I used the following version of the JDK: jdk1.5.0_21). You might need to add the JDK bin/ directory to your PATH in order for Java to work correctly. You can tests your settings by entering “java -version” in the command line prompt.
After the installation of the JDK, install Apache Ant (this article uses version 1.8.1) into a directory of your choice. I used “D:\apache\ant\” as the home folder for ANT. Add the following environment variable (modify according to your settings):
ANT_HOME=D:\apache\ant\
Building the Wrapper
Now, download the source code from the Tanuki Software website (Link to download site) and extract it to a convenient location such as D:\work\wrapper_3.4.1_src
. Then, we need to apply some modifications to the build file in order to create the x64 version. Here are the instructions:
- Descend into the folder
src\c
and copy the fileMakefile-windows-x86-32.nmake
toMakefile-windows-x86-64.nmake
- On line 12, remove the argument “
/Zp4
” (seems to cause “Stdout pipecreation failed
“) - On line 13, change “
/MACHINE:X86
” to “/MACHINE:AMD64
“ - On line 17, change “
$(PROJ)32_VC8__Win32_Release
” to “$(PROJ)32_VC8__Win64_Release
“ - On line 24, change “
$(PROJ)JNI32_VC8__Win32_Release
” to “$(PROJ)JNI32_VC8__Win64_Release
“ - On line 19 and 26, add the string “
bufferoverflowU.lib
” (without quotes)
Pro tip: Download one of my released wrappers and use my “Makefile-windows-x86-64.nmake
” to make sure you didn’t miss anything.
Then, return to the root folder (e.g. “D:\work\wrapper_3.4.1_src
“) and run the file “build64.bat
“. You might need to edit the Batchfile and add the following line above the line beginning with “call
“:
set ANT_HOME=D:\apache\ant
The build process should now be started.
After a successful build, you can test the wrapper by launching “TestWrapper.bat
” in the “bin/
” directory.
To distribute the wrapper, the following three files are necessary:
bin\wrapper.exe
lib\wrapper.dll
lib\wrapper.jar