你还是必须用VC写一个服务的shell, 然后再这个shell中调用java虚拟机。tomcat就是这么做的。

解决方案 »

  1.   

    用RMI也许可以,
    把你的java程序嵌入RMI server端的impl中,这样它就可以像服务一样随时被
    调用,然后你可以把rmiregistry 和运行rmi server都做成bat, 放在windows的启动里就可以了。我以前做过类似的事情。
      

  2.   

    可否提供相关的实现方法或者是粗略的code呢?谢谢!
      

  3.   

    有一个程序是专门把java程序做成服务的。是一个exe文件,加不同的参数。
    tomcat的bin下面的tomcat.exe就是这个文件。其实是javaservice.exe。
    给你个tomcat的例子,如果想要全部文档的程序给我发的信,我给你发过去。
    [email protected] is a JSP engine and was the primary reason that JavaService was created. It is a pure Java application that is ideally used as a service, but comes with no native ability to do so. The following example shows how JavaService can be used to run Tomcat 3.1 as an NT service. The ideas shown here apply to using JavaService with any Java application that needs to run as an NT service. {JDK_HOME} is the location of your JDK and {TOMCAT_HOME} is the location of your Tomcat installation.Copy the JavaService.exe file into the{TOMCAT_HOME}\bin directory as tomcat.exe. 
    Start a command prompt and change to the directory {TOMCAT_HOME}\bin. 
    Run the following command:
    tomcat.exe -install Tomcat
    {JDK_HOME}\jre\bin\{hotspot|server|classic}\jvm.dll
    -Djava.class.path={TOMCAT_HOME}\bin\bootstrap.jar;{TOMCAT_HOME}\bin\servlet.jar;{JDK_HOME}\lib\tools.jar 
    -Dcatalina.home={TOMCAT_HOME}
    -start org.apache.catalina.startup.Bootstrap
    -params start
    -stop org.apache.catalina.startup.Bootstrap
    -params stop
    -out {TOMCAT_HOME}\logs\stdout.log
    -err {TOMCAT_HOME}\logs\stderr.log 
      

  4.   

    国庆快乐!
    太感谢各位兄弟!特别是xue_sharp(你是自愿被我泡的) !
    我给你发了邮件,希望你能顺利收到,呵呵.这是和一个朋友在一起讨论的时候碰到的问题,现在有了答案,不深感激!