简体   繁体   English

执行jar文件时出现FileNotFound异常

[英]FileNotFound exception when executing jar file

I'm creating a epubchecker gui using c# 我正在使用C#创建一个epubchecker gui

there is a free epubchecker written in java. 有一个用Java编写的免费epubchecker。

its call epubcheck 它的呼叫epubcheck

to run using command line 使用命令行运行

java -jar epubcheck.jar file.epub

and my c# code is 我的C#代码是

System.Diagnostics.Process clientProcess = new Process();
clientProcess.StartInfo.FileName = "java";
clientProcess.StartInfo.Arguments = @" -jar " + @"C:\Users\User\Documents\Visual Studio 2015\Projects\epubcheck-4.0.1\epubcheck.jar" + " " + @"C:\Users\User\Desktop\v3.epub";
clientProcess.Start();
clientProcess.WaitForExit();

and the error is 错误是

The system cannot find the path specified

but i checked the location of the jar file and epub 但我检查了jar文件和epub的位置

i copied the string on my program and pasted the string on file explorer. 我将字符串复制到程序中,并将该字符串粘贴到文件资源管理器中。 and the file and folder exist. 并且文件和文件夹存在。

so what am i doing wrong? 那我在做什么错?

java path添加到环境path变量。

由于文件路径中有空格,因此需要将其用引号引起来:

clientProcess.StartInfo.Arguments = @" -jar " + @"""C:\Users\User\Documents\Visual Studio 2015\Projects\epubcheck-4.0.1\epubcheck.jar""" + " " + @"""C:\Users\User\Desktop\v3.epub""";

尝试这个

   clientProcess.StartInfo.Arguments = @" -jar " + @"C:\\Users\\User\\Documents\Visual Studio 2015\\Projects\\epubcheck-4.0.1\\epubcheck.jar" + " " + @"C:\\Users\\User\\Desktop\\v3.epub";

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM