java.io.IOException: Cannot run program “…”: java.io.IOException: error=2, No such file or directory

后端 未结 3 1029
时光说笑
时光说笑 2020-12-11 18:03

I need to execute an external program from Java (to convert a fodt file to pdf using libreoffice, it so happens) I know the precise command-line I need for

3条回答
  •  执念已碎
    2020-12-11 18:36

    I have tried every solution proposed in this thread and it does not work.

    In my app (java webapp using TOMCAT in linux) it only works to create a shell script and execute the script. But you have to put the absolute path in the script, if not, it does not work ($HOME does not work). Besides, you can pass it arguments.

    Example:

    Runtime.getRuntime().exec("/home/user/myscript.sh param1");
    

提交回复
热议问题