How to execute a Java program from C#?

前端 未结 7 2111
遥遥无期
遥遥无期 2020-11-30 01:24

Wondering if anyone knows a nice way to execute a Java command-line program from C# code at run-time ?

Is it the same as executing native .EXE files ?

Wi

7条回答
  •  盖世英雄少女心
    2020-11-30 01:58

    It's the same as executing native .EXE files, only that the executable you will have to execute is the JVM itself (java.exe).

    So, inside your C# code call:

    java.exe -jar nameofyourjavaprogram.jar

    And you should be fine.

    If you don't have your java program on a JAR library, just make the JVM launch with all the parameters you need.

提交回复
热议问题