there is a class:

DesktopApi.java 

With Method: public static boolean runCommand (String command, String args, String file) {

  String cmd = "soffice --invisible -p '/media/user/UBUNTU18_0/welcome.doc'"; try { Process p = Runtime.getRuntime().exec(cmd); System.out.println(cmd); try { p.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } try { int retval = p.exitValue(); System.out.println("Process exitValue: " + retval); if (retval == 0) { logErr("Process ended immediately."); return false; } else { logErr("Process crashed."); return false; } } catch (IllegalThreadStateException itse) { itse.printStackTrace(); logErr("Process is rnnuing."); return true; } }catch (IOException e) { logErr("Error running command.", e); return false; } } 

The method attempts to print a .doc file via bash using libre. But he is unable to execute the command.

No errors. But the result too.

When you launch Libre without arguments, the software opens without problems, but after adding to print ... It does not respond at all.

System UBUNTU 18_0.

    1 answer 1

    After a long search for a solution, I found how to fix it.

    1) I downloaded Apache Commons Exec and embedded it in my project.

    http://commons.apache.org/proper/commons-exec/

    2) I registered this code

     String line = "ВАША КОМАНДА ДЛЯ ВЫПОЛНЕНИЯ"; CommandLine commandLine = CommandLine.parse(line); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(1); int exitValue = executor.execute(commandLine);