Runtime.getRuntime().exec("文件的位置")

        try {
            Runtime.getRuntime().exec("文件名");
        } catch (IOException e) {
            e.printStackTrace();
        }

脚本

        String res = "";
        List<String> processList = new ArrayList<String>();
        try {
            Process process = Runtime.getRuntime().exec("/home/java/jar/restart12347.sh");
            BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = "";
            while ((line = input.readLine()) != null) {
                processList.add(line);
            }
            input.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (String line : processList) {
            System.out.println(line);
            res = res + line;
        }
特殊说明:
上述文章均是作者实际操作后产出。烦请各位,请勿直接盗用!转载记得标注原文链接:www.zanglikun.com
第三方平台不会及时更新本文最新内容。如果发现本文资料不全,可访问本人的Java博客搜索:标题关键字。以获取最新全部资料 ❤