cmd - Eclipse RCP cmd 提示处理程序
问题描述
我正在开发和应用 eclipse rcp 框架(3.0)。我想在运行菜单中创建一个 Eclipse RCP 命令,将 shell 命令发送到 windows cmd 提示符。
如何通过事件触发它?
public class RunCmd extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// I need to get runtime exec
}
}
解决方案
用于执行 Windows 命令提示符的示例代码。
有不同的方法可用于检查过程是否正确执行
public class SampleHandler extends AbstractHandler {
public static final String ID = "com.example.views.play";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
String command = "adb shell input key 26";
try
{
Process process = Runtime.getRuntime().exec(command);
} catch (IOException e)
{
e.printStackTrace();
}
return null;
}
}
推荐阅读
- c++ - 使用三元运算符时的C++ std::length_error?
- javascript - 如何在浏览器 (Chrome) 中从我的应用创建视频?
- firebase - firebase 动态链接中是否有任何内置功能使其对一次性使用有效
- python - 用前几行的平均值填充 NaN 值?
- javascript - 如何在axios create上导入localstorage数据
- r - 在多个虚拟变量的 R 中创建数据框的子集
- programming-languages - 证明给定语言中函数的不可表达性
- rust - 如果我有嵌套的 async/await 调用,我应该关心累积的开销吗?
- gitlab-ci - 带有日期的 Docker 标记在 Gitlab 中不再起作用
- javascript - 无法使用选择隐藏和显示字段