[英]i want to execute a precompiled java class file from a MVC action.the class file is placed with in the C# project folder.
i want to execute a precompiled java class file from a MVC action.the class file is placed with in the C# project folder. 我想从MVC操作执行一个预编译的Java类文件。该类文件与C#项目文件夹中放置在一起。 But Still it throws File Not Found Exception.
但是仍然会引发“文件未找到”异常。
`Process myProcess = new Process(); `Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
//File not Found Exception Appears Here
myProcess.StartInfo.FileName = @"java JDKTest2";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();`
You need to pack java class to a jar and call it like this: 您需要将Java类打包到jar中,并按如下方式调用它:
myProcess.StartInfo.UseShellExecute = false;
//File not Found Exception Appears Here
myProcess.StartInfo.FileName = "java";
myProcess.StartInfo.Arguments = @"-jar JDKTest2.jar";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
Also make sure the paths to java
and JDKTest2.jar
are known in this context or switch to absolute path. 还要确保在此上下文中知道
java
和JDKTest2.jar
的路径,或切换到绝对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.