Execute bash command within java program

后端 未结 2 1739
一向
一向 2021-01-24 22:25

It\'s been quite a while since I\'m looking for but I don\'t find the solution. I\'m trying to execute bash command on Linux within .jar file. For that, I tried many things, in

2条回答
  •  庸人自扰
    2021-01-24 23:13

    I think the easiest way to do this would be to create a shell script (.sh extension) and then you can easily run that from within the Java program. There is a good answer on a previous question on how to run shell scripts within Java here.

    To create a shell script you can use any text editor and create a file with the extension .sh and just enter the lines as you would in the bash terminal.

提交回复
热议问题