linux 下 java 执行 shell 命令
2011-02-10 16:05
786 查看
以下是通过java执行shell命令启动hypertable 数据库的 例子。
/** * 启动数据库服务 * @return */ public String startUp() { // 此处的命令是写死的, String commands = "ht start all-servers local"; //String commands = "ping 192.168.1.100"; Process p ; try { p = Runtime.getRuntime().exec(commands); if(p.waitFor()==0) { msg = "服务启动成功!"; } else { msg = "服务启动失败!"; } } catch (IOException e) { msg = "服务启动失败!"; e.printStackTrace(); } catch (InterruptedException e) { msg = "服务启动失败!"; e.printStackTrace(); } catch (Exception e) { msg = "服务启动失败!"; e.printStackTrace(); } return "ok"; }
相关文章推荐
- windows 下 java程序jsch连接远程linux服务器执行shell命令
- linux的shell命令检测某个java程序是否执行
- Java调用linux系统shell执行命令
- java本地调用cmd,shell命令,远程调用Linux执行命令方法总结
- java 执行linux命令或shell脚本方法
- java Windows下cmd 命令和Linux下shell命令 执行非JDK中的jar包
- Java实现ssh连接linux并执行shell命令
- linux 使用 java 程序执行 shell命令
- linux的shell命令检测某个java程序是否执行
- java本地调用cmd,shell命令,远程调用Linux执行命令方法总结
- Linux远程执行shell命令
- 执行文件下载Java 调用 FFMPEG 命令时用 url 作为输入源,Linux 下出现 “no such file or directory” 问题的解决
- Linux下使用popen()执行shell命令
- linux远程批量执行命令的shell脚本
- java 中调用window系统中的文件,或者执行命令(shell、.CMD、.EXE)并获取返回值(如果有的话)
- java调linux的shell命令
- linux下shell脚本执行方法及exec和source命令
- paip.执行shell cmd 命令uapi java php python总结
- linux执行java应用的shell
- Java 连接远程Linux 服务器执行 shell 脚本查看 CPU、内存、硬盘信息