Hi, I want to run something from the command line using java
I want to go to the following directory C:\Program Files\OpenOffice.org 3\program\ and then run soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
I tried, but I am not able to do it!
my code
public static void main(String[] args) { // TODO Auto-generated method stub try { Runtime rt = Runtime.getRuntime(); //Process pr = rt.exec("cmd /c dir"); // Process pr = rt.exec("cmd /c dir"); Process pr = rt.exec(new String[]{"C:\\Program Files\\OpenOffice.org 3\\program\\soffice", "-headless", "-accept='socket,host=127.0.0.1,port=8100;urp;'", "-nofirststartwizard"}); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line=null; while((line=input.readLine()) != null) { System.out.println(line); } int exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } }
source share