java程序用做windows服务

具体步骤在这里

http://www.doc88.com/p-360144091164.html

 

遇到错误:

JVM did not exit on request, terminated 

通过下面的方式解决

 

 

import   org.tanukisoftware.wrapper.WrapperActionServer;  

  import   org.tanukisoftware.wrapper.WrapperManager;  

  import   org.tanukisoftware.wrapper.WrapperListener;  

  import   org.tanukisoftware.wrapper.event.WrapperEventListener;  

   

  public   class   HelloWorld   implements   WrapperListener{  

           

          private   HelloWorld()   {  

          }  

   

          public   Integer   start(   String[]   args   ){  

                  System.out.println(   "start()"   );  

   

                  try{  

                          System.out.println("HelloWorld!");  

                  }  

                  catch   (   Exception   e   ){}  

                  return   null;  

          }  

           

          public   int   stop(   int   exitCode   ){  

                  System.out.println(   "stop("   +   exitCode   +   ")"   );  

                  return   exitCode;  

          }  

           

          public   void   controlEvent(   int   event   ){  

                  System.out.println(   "controlEvent("   +   event   +   ")"   );  

          }  

           

          public   static   void   main(   String[]   args   ){  

                  System.out.println(   "Initializing..."   );  

                  WrapperManager.start(   new   HelloWorld(),   args   );  

          }   

 

你可能感兴趣的:(windows)