JAVA代碼如下: try { Runtime rt = Runtime.getRuntime(); String str[] = {"/bin/sh", "-c", "/usr/hadoop-0.19.0/bin/load.sh"}; Process pcs = rt.exec(str); BufferedReader br = new BufferedReader(new InputStreamReader(pcs.getInputStream())); String line = new String(); if(textarea.getText()!=null) textarea.setText(""); while ((line = br.readLine()) != null) { textarea.append(line); textarea.append("\n"); } try { pcs.waitFor(); } catch (InterruptedException e) { System.err.println("processes was interrupted"); } br.close(); } catch (Exception e) { e.printStackTrace(); } Shell文件如下: #!/bin/sh bin/hadoop fs -mkdir input bin/hadoop fs -put input1.txt input
為什么不能正確運(yùn)行shell文件,但是linux終端下面可以正確運(yùn)行shell文件?
慕的地8271018
2023-03-21 19:15:05