views:

34

answers:

1

I would like to wrap a java application as a Windows Service using C#. 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. I'm looking to fully wrap the java application, including the java process.

Does anybody here has done it or knows the best way to do this in C#?

+1  A: 

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. There isn't a direct way to do this in C#, as the JNI interfaces for hosting are C++ interfaces only.

However, there are commerical products that allow you to do this directly from Java.

Reed Copsey
I want to make one to have a better control and to ensure some guarantees.
jonaspp
@jonaspp: You may be able to P/Invoke into the JNI calls, but it's going to be very ugly... I don't know of any existing wrappers, though.
Reed Copsey
Thanks man... I will take a look into this...
jonaspp