[英]Execute .jar from windows form C#
I have .jar to execute from windows from, so far I was able to lunch the program from my window form, but when I put information in my java file I get no result the java file does nothing. 我有.jar可以从Windows中执行,到目前为止,我已经可以从窗口窗体中午餐该程序了,但是当我在Java文件中放入信息时,我没有得到任何结果,Java文件什么也不做。 If I go manualy double click and execute the .jar file and put the information I get the resul. 如果我手动进行双击,然后执行.jar文件,然后输入信息,即可得到结果。
here is my code to execute java inside windows form : 这是我在Windows窗体内执行Java的代码:
Process p = Process.Start(@"C:\convert\Convert.jar");
Thread.Sleep(500);
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, this.Handle);
.jar file is for to convert .csv to .txt with special data. .jar文件用于将.csv转换为具有特殊数据的.txt。
To run a jar, you need to use 要运行一个罐子,您需要使用
java -jar <FILENAME.jar>
In your case it would be 在你的情况下
Process p = Process.Start(@"java -jar C:\convert\Convert.jar");
Thread.Sleep(500);
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, this.Handle);
Here is the solution : 这是解决方案:
System.Diagnostics; ... ProcessStartInfo _processStartInfo = new ProcessStartInfo();
_processStartInfo.WorkingDirectory = @"%ProgramFiles%";
_processStartInfo.FileName = @"Notepad.exe";
_processStartInfo.Arguments = "test.txt";
_processStartInfo.CreateNoWindow = true;
Process myProcess = Process.Start(_processStartInfo);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.