0

I am trying to run a java app in the background. its simple command - java -jar app.jar

If we run above command on powershell cli - its working fine but not in the background

Few thing i tried

Start-Job -Command {java -jar .\app.jar} Also tried "start command"

it is listing the jobs but its not running the app. Do we have a way something like "&"

Please suggest

Springhills
  • 360
  • 1
  • 5
  • 12
  • I guess the correct syntax will be: Start-Job -ScriptBlock {java -jar .\app.jar} – Mar-Z Jun 20 '23 at 18:04
  • 1
    Beginning in PowerShell 6.0, you can start jobs using the ampersand (&) background operator. – Mar-Z Jun 20 '23 at 18:06
  • In short: In _Windows PowerShell_ (versions up to v5.1), the working directory for `Start-Job` is the user's _Documents_ directory, not the _caller's_ current directory; changing to the caller's / a given directory requires an explicit `Set-Location` call as part of the script block (or via a separate script block passed to `-InitializationScript` ). In _PowerShell (Core) 7+_, the caller's working directory is now inherited by default, and a new `-WorkingDirectory` parameter allows specifying a directory explicitly. See the linked duplicate for details. – mklement0 Jun 21 '23 at 01:46

0 Answers0