jdeploy icon indicating copy to clipboard operation
jdeploy copied to clipboard

Runtime.getRuntime().exec doesn't work

Open theapache64 opened this issue 3 years ago • 8 comments

When running JAR directly, Runtime.getRuntime().exec("git") works, but running via the installed command, it doesn't work.

Exception in thread "main" java.io.IOException: Cannot run program "git": error=2, No such file or directory
        at java.base/java.lang.ProcessBuilder.start(Unknown Source)
        at java.base/java.lang.ProcessBuilder.start(Unknown Source)
        at java.base/java.lang.Runtime.exec(Unknown Source)
        at java.base/java.lang.Runtime.exec(Unknown Source)

Any idea?

theapache64 avatar Feb 18 '22 20:02 theapache64

What operating system? Is it a GUI app, or are you running through the CLI? Installed via npm install or via double-clickable desktop installer?

Are both running in same terminal environment? (in same terminal window)?

shannah avatar Feb 18 '22 20:02 shannah

What operating system?

macOS

Is it a GUI app, or are you running through the CLI?

CLI

Installed via npm install or via double-clickable desktop installer?

Installed via sudo jdeploy install

Are both running in same terminal environment? (in same terminal window)?

Yes

theapache64 avatar Feb 18 '22 21:02 theapache64

You might want to check the environment (e.g. System.getenv()) to see what the difference is. Particularly in the PATH environment variable.

shannah avatar Feb 18 '22 22:02 shannah

Both are same. Confirm

theapache64 avatar Feb 18 '22 23:02 theapache64

UPDATE: The issue is not there in 1.022. I think its a regression came in ^3.0.0

theapache64 avatar Feb 18 '22 23:02 theapache64

Is it the same java version?

shannah avatar Feb 19 '22 00:02 shannah

Yes. Steps to reproduce

  1. Create a new gradle based Kotlin project
  2. Call Runtime.getRuntime.exec("git")
  3. Export jar
  4. Run jar through terminal java -jar my.jar (this will work)
  5. Now install app using sudo jdeploy install and run the app from terminal

theapache64 avatar Feb 19 '22 01:02 theapache64

Those will be different versions of java.

Please post output of both system properties and env vars printed from inside the java app.

shannah avatar Feb 19 '22 01:02 shannah