SlideShare a Scribd company logo
1 of 7
Download to read offline
Windows Service
in JAVA
Windows Service JAVA with procrun




11/26/2012
arifnasution@ymail.com

   1. Create java application project in “netbeans”.




   2. Create main class with name Driver with 2 attributes (Logger with name log and Boolean with name stop
      attributes), 3 static methods (main, start and stop) and fill the class with source code like this picture.




                                                                                                                    1
arifnasution@ymail.com

   3. Create log4j.properties.




   4. Add log4j jar library to your project.




                                               2
arifnasution@ymail.com

   5. Clean and build project to create jar file.




   6. Go to your project folder, and you will find “dist” folder which generated from build and clean process.




                                                                                                                 3
arifnasution@ymail.com

   7. Go to “dist” folder and copy all files inside it




   8. Create a folder for your windows service and paste all files from “dist” folder. In this sample, I create
      “sample_windows_service” folder in drive d and copy procrun.exe & procrunmgr.exe to your folder and rename
      it (I rename it into java_windows_service.exe & java_windows_service_mgr.exe).




                                                                                                               4
arifnasution@ymail.com

   9. Run your renamed procrun exe (java_windows_service.exe) with this script.

 java_windows_service.exe //IS//SampleService --Install="D:sample_windows_servicejava_windows_service.exe" --Jvm=auto --
    Startup=auto --StartMode jvm --StartClass sample.windows.service.Driver --StartParams start --StopMode jvm --StopClass
   sample.windows.service.Driver --StopParams stop --Classpath="D:sample_windows_servicejava_windows_service.jar" --
                                            DisplayName="Sample Service JAVA"




   10. You will find “Sample Service JAVA” in services.msc.




                                                                                                                             5
arifnasution@ymail.com

   11. Start “Sample Service JAVA”.




   12. Check your log file path and you will find it if you succeed.




                                                          = Thank you =

                                                                          6

More Related Content

Similar to Tutorial windows service with java (procrun)

Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)QA Programmer
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applicationstechbed
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsSteve Keener
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Amit Singh
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Gopi Raghavendra
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applicationselliando dias
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010Tim Clark
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 stepsIshara Amarasekera
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialRaghavan Mohan
 
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDE
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDESpring Data JPA + JSF + Maven + Mysql using Eclipse IDE
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDENikhil Bhalwankar
 
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with EclipseNikhil Bharati
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityDanHeidinga
 
Java interview question
Java interview questionJava interview question
Java interview questionsimplidigital
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Robert Scholte
 

Similar to Tutorial windows service with java (procrun) (20)

Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
 
Part 5 running java applications
Part 5 running java applicationsPart 5 running java applications
Part 5 running java applications
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Profiling documentforaltrec
Profiling documentforaltrecProfiling documentforaltrec
Profiling documentforaltrec
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 steps
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDE
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDESpring Data JPA + JSF + Maven + Mysql using Eclipse IDE
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDE
 
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with Eclipse
 
Installing java, eclipse and maven
Installing java, eclipse and mavenInstalling java, eclipse and maven
Installing java, eclipse and maven
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after Modularity
 
Gradle
GradleGradle
Gradle
 
Java interview question
Java interview questionJava interview question
Java interview question
 
Arquillian in a nutshell
Arquillian in a nutshellArquillian in a nutshell
Arquillian in a nutshell
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
 

More from muhammad arif nasution

More from muhammad arif nasution (9)

Excel to html
Excel to htmlExcel to html
Excel to html
 
Hello World Android v.01
Hello World Android v.01Hello World Android v.01
Hello World Android v.01
 
Tutorial Hello World Web Services with Apache CXF
Tutorial Hello World Web Services with Apache CXFTutorial Hello World Web Services with Apache CXF
Tutorial Hello World Web Services with Apache CXF
 
Sample jasper report (design with IReport & code sample)
Sample jasper report (design with IReport & code sample)Sample jasper report (design with IReport & code sample)
Sample jasper report (design with IReport & code sample)
 
SSIS 2005 training kit v0.01
SSIS 2005 training kit v0.01SSIS 2005 training kit v0.01
SSIS 2005 training kit v0.01
 
Tutorial web service (web & client) with spring web services
Tutorial web service (web & client) with spring web servicesTutorial web service (web & client) with spring web services
Tutorial web service (web & client) with spring web services
 
Tutorial java & mysql
Tutorial java & mysqlTutorial java & mysql
Tutorial java & mysql
 
Tutorial text database (hsqldb)
Tutorial text database (hsqldb)Tutorial text database (hsqldb)
Tutorial text database (hsqldb)
 
Cv muhammad arif nasution
Cv muhammad arif nasutionCv muhammad arif nasution
Cv muhammad arif nasution
 

Tutorial windows service with java (procrun)

  • 1. Windows Service in JAVA Windows Service JAVA with procrun 11/26/2012
  • 2. arifnasution@ymail.com 1. Create java application project in “netbeans”. 2. Create main class with name Driver with 2 attributes (Logger with name log and Boolean with name stop attributes), 3 static methods (main, start and stop) and fill the class with source code like this picture. 1
  • 3. arifnasution@ymail.com 3. Create log4j.properties. 4. Add log4j jar library to your project. 2
  • 4. arifnasution@ymail.com 5. Clean and build project to create jar file. 6. Go to your project folder, and you will find “dist” folder which generated from build and clean process. 3
  • 5. arifnasution@ymail.com 7. Go to “dist” folder and copy all files inside it 8. Create a folder for your windows service and paste all files from “dist” folder. In this sample, I create “sample_windows_service” folder in drive d and copy procrun.exe & procrunmgr.exe to your folder and rename it (I rename it into java_windows_service.exe & java_windows_service_mgr.exe). 4
  • 6. arifnasution@ymail.com 9. Run your renamed procrun exe (java_windows_service.exe) with this script. java_windows_service.exe //IS//SampleService --Install="D:sample_windows_servicejava_windows_service.exe" --Jvm=auto -- Startup=auto --StartMode jvm --StartClass sample.windows.service.Driver --StartParams start --StopMode jvm --StopClass sample.windows.service.Driver --StopParams stop --Classpath="D:sample_windows_servicejava_windows_service.jar" -- DisplayName="Sample Service JAVA" 10. You will find “Sample Service JAVA” in services.msc. 5
  • 7. arifnasution@ymail.com 11. Start “Sample Service JAVA”. 12. Check your log file path and you will find it if you succeed. = Thank you = 6