从 C# 运行 Jar 文件
给定的代码是用于在 C# 环境中运行 jar 文件的代码的一部分。 完整代码
strArguments = " -jar "+ Argument list;
processJar.StartInfo.FileName = "\"" + @"java" + "\"";
processJar.StartInfo.Arguments = strArguments;
processJar.StartInfo.WorkingDirectory =; \\Give the working directory of the application;
processJar.StartInfo.UseShellExecute = false;
processJar.StartInfo.RedirectStandardOutput = true;
我知道 processJar.StartInfo.FileName 应该包含jave.exe 以便在进程启动时触发相应的文件。但上面给出的代码也运行成功。
问题: 这里的 "\"" + @"java" + "\"" 是什么意思?如果我提供这样的输入,系统本身会搜索java.exe吗?
Given code was a part of the code used to run a jar file on c# environment. Complete Code
strArguments = " -jar "+ Argument list;
processJar.StartInfo.FileName = "\"" + @"java" + "\"";
processJar.StartInfo.Arguments = strArguments;
processJar.StartInfo.WorkingDirectory =; \\Give the working directory of the application;
processJar.StartInfo.UseShellExecute = false;
processJar.StartInfo.RedirectStandardOutput = true;
I know that processJar.StartInfo.FileName should contain the jave.exe so that the respective file will be triggered when the process gets started. But the above given code also runs successfully.
Question:
What does "\"" + @"java" + "\"" here? If I provide such input will the system itself will search java.exe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们只是确保字符串为
"java"
(带引号)。当您的路径包含空格时,通常需要这样做。
如果路径包含空格(例如
"C:\Program Files"
),则 Windows 要求将路径加引号。至于查找可执行文件 - 如果 java 可执行文件的路径位于
%PATH%
环境变量中,则会找到它。在这种情况下,它们似乎是多余的。
They simply ensure that the string will be
"java"
(with the quotes).This is normally needed when you have a path that contains spaces.
Windows requires the path to be quoted if it contains spaces (for example
"C:\Program Files"
).As for finding the executable - if the path to the java executable is in the
%PATH%
environment variable, it will be found.In this case they seem superfluous.
它是需要启动的exe名称
its the exe name which needs to be launched