Registering a Java jar package with Javaservice as a Windows service

Source: Internet
Author: User
Tags goto

First, download the Javaservice, unzip the compressed files and put them on the local disk.

Javaservice 64-bit Http://download.forge.ow2.org/javaservice/JavaService_2_0_10-amd64.zip
Javaservice 32-bit Http://download.forge.ow2.org/javaservice/JavaService-2.0.10.zip
Second, prepare the jar package to see the jar package the class where the main function is located

Third, the jar package, decompression javaservice execution program, JDK free installation package in the same folder, and under the file to create new Err.log and Out.log files.
Four, after the registration may encounter "The LoadLibrary function failed for the following reason can not find the solution of the specified module" problem, in order to avoid the problem, the first processing.
Method 1: Copy the%java_home%/bin/msvcr100.dll file to the C:\Windows\System32,
If it is a 64-bit system, copy it to C:\Windows\SysWOW64.
Method 2: Copy the%java_home%/bin/msvcr100.dll file into the same directory as the JAVA program packaged into the jar file
Using the second method, copy the Java-1.8.0_172\jre\bin\msvcr100.dll to the directory where the Java program jar package is located, which is structured as follows:

The Start.bat file is empty at this time
Files stored under the app directory

V. Writing a bat script (start.bat)
@echo off

REM Get the current path
Set c_path=%cd%

REM Get the installation path
set/p "I_path=please Enter the installation PATH:"

REM Check whether the installation path exists.
REM If the path already exists, exit.
rem If no exists,creation installation path.
If exist%i_path% goto I_path_exit
If not exist%i_path% goto I_path_ont_exit

: I_path_exit
echo%i_path% already exist, please replace
set/p "I_path=please Enter the installation PATH:"
If exist%i_path% goto I_path_exit
If not exist%i_path% goto I_path_ont_exit

: I_path_ont_exit
mkdir%i_path%\app

rem echo Copy the file to the installation directory
rem xcopy directory, copy file
xcopy%c_path%\app%i_path%\app/s

@ Timeout 3
REM Register as a service
%i_path%\app\javaservice.exe-install hello-test "%i_path%\app\java-1.8.0_172\jre\bin\server\jvm.dll"-Xms256m- Xmx1024m-jar-djava.class.path= "%i_path%\app\java-1.8.0_172\lib\tools.jar;%i _path%\app\helloworld.jar "-start" Org.springframework.boot.loader.JarLauncher "-out"%i_path%\app\out.log "-err"%I _path%\app\err.log "-current"%c_path% "-auto
@ Timeout 5
net start Hello-test

REM Generate configuration file
echo System installation path:%i_path%\app >%c_path%\confing.txt
echo system startup command: Net start hello-test >>%c_path%\confing.txt
echo System shutdown command: net stop hello-test >>%c_path%\confing.txt
Echo can start or shut down the system via the service (powered on from boot) >>%c_path%\confing.txt
echo system service Uninstall command: SC delete hello-test >>%c_path%\confing.txt
Pause
Note:-start "Org.springframework.boot.loader.JarLauncher" –start the class name found in the second step
VI. testing on the Windows 10 operating system (double-click the Start.bat file)

See the above page, stating that the service registration is successful, and has been started, press any key to exit.

Vii. Viewing the management documentation

Confing.txt automatically generated after the service has been successfully started

Viii. viewing the installation path file

Where the service startup log is logged in the Out.log file
Ix. Reference Documents
41862831

Registering a Java jar package with Javaservice as a Windows service

Related Article

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.