简体   繁体   English

我想从MVC操作执行一个预编译的Java类文件。该类文件与C#项目文件夹中放置在一起。

[英]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. 还要确保在此上下文中知道javaJDKTest2.jar的路径,或切换到绝对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编辑放置在类文件夹中的文件 - Edit file placed in class folder 执行使用jar文件中的类的Java类文件 - Execute a java class file that uses class from a jar file 如何在Maven项目中从C运行Java类文件 - How to run java class file from C inside a Maven project 我在资产文件夹中有一个文本文件。 如何从该文本文件访问随机句子? - I have a text file in the assets folder. How can I access a random sentence from that text file? FileNotFoundException即使将文件与类文件放在同一文件夹中 - FileNotFoundException even when file placed in the same folder as the class files 无法执行 Java 类文件 - Unable to Execute Java Class File 如何从我的servlet类访问放在/ tmp文件夹中的sqlite db文件? - How to access my sqlite db file placed in /tmp folder from my servlet class? Google Drive Java Api-文件夹中的更新文件。 - Google Drive Java Api - update file in the folder. 我不想在 Selenium 和 Java 中制作文件上传方法时将 Thread.sleep() 与 Action class 一起使用 - I don't want to use Thread.sleep() with Action class while making the method for file upload in Selenium and Java 我可以执行Java类文件的多个实例吗? - Can I execute multiple instances of a Java class file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM