我正在从C#控制台应用程序启动jar文件。问题是,jar控制台窗口消失得太快,我没有时间看到结果。对于运行jar文件的C#代码的这种特定情况,我似乎在Google上找不到任何内容。我所看到的就是如何使控制台窗口在Visual Studio中不消失,这不是我想要的。
这是C#代码:
private static void Main(string[] args)
{
string path = "C:\\Example";
Process process = new Process();
process.EnableRaisingEvents = false;
process.StartInfo.FileName = "java.exe";
process.StartInfo.Arguments = "-jar " + '"' + path + "\\Animal.jar";
process.Start();
Console.ReadKey();
}
和jar文件中的代码:
public static void main(String[] args) throws IOException {
Animal dog= new Animal();
dog.id=4; dog.name="Jaka";
System.out.println("My dog's name is "+ dog.getName());
}
如何使jar控制台窗口不消失?