简体   繁体   English

Java运行时错误

[英]Java Runtime Error

I am using the following code to try and retrieve information from the Windows Task Manager: 我正在使用以下代码尝试从Windows任务管理器中检索信息:

Runtime.getRuntime().exec("tasklist /v /fi");

When I enter "tasklist /v /fi" into windows CMD it works, but in java it gives me the error that the file path could not be found. 当我在Windows CMD中输入“ tasklist / v / fi”时,它可以工作,但是在Java中,它给我一个错误,即找不到文件路径。

使用字符串数组运行带有多个选项的命令。

Runtime.getRuntime().exec(new String[]{"tasklist","/v","/fi"});

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

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