简体   繁体   English

使用C#将Java应用程序作为Windows服务

[英]java application as a Windows Service using C#

I would like to wrap a java application as a Windows Service using C#. 我想使用C#将Java应用程序包装为Windows服务。 I can do it easily using the Process class and calling Process.Start("java.exe", "args") , but doing this way I have 2 process, my service wrapper and the java process. 我可以使用Process类并调用Process.Start("java.exe", "args")轻松完成此操作,但是这样做,我有2个进程,即服务包装程序和Java进程。 I'm looking to fully wrap the java application, including the java process. 我希望完全包装Java应用程序,包括Java进程。

Does anybody here has done it or knows the best way to do this in C#? 这里有没有人做过或者知道用C#做到最好的方法?

The two basic approaches are to either run the Java application as a separate process, or to host the JVM directly, and use it to launch your application. 这两种基本方法是将Java应用程序作为一个单独的进程运行,或者直接托管JVM,然后使用它来启动应用程序。 There isn't a direct way to do this in C#, as the JNI interfaces for hosting are C++ interfaces only. 在C#中没有直接的方法来执行此操作,因为用于托管的JNI接口仅是C ++接口。

However, there are commerical products that allow you to do this directly from Java. 但是,有些商业产品允许您直接从Java执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM