从 C# 运行 Jar 文件

发布于 2024-10-07 11:13:14 字数 685 浏览 0 评论 0原文

给定的代码是用于在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

得不到的就毁灭 2024-10-14 11:13:14

他们只是确保字符串为 "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.

奢华的一滴泪 2024-10-14 11:13:14

它是需要启动的exe名称

its the exe name which needs to be launched

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文