javapowershellpowershell-2.0powershell-3.0

PowerShell - Check if Java Application is running, if not - restart it. (Javaw.exe doesn't show details)


I've had a good search around, but can't quite find what I'm looking for.

We have Java applications running 24/7 on several remote machines which intermittently crashes (We think the application's devs are working on it) but for the time being, we need a way of restarting this application should it fail.

Now... the tricky thing is, as far as I can see at least, is that there's no way of telling if the application is running at all as only Javaw.exe shows in task manager. Even with the command line column, it only points to javaw.exe.

The reason we can't just check if Javaw is running, is because we have another Java application that isn't used as much (it's like a web based CRM software) This also starts Javaw.exe when needed, and also doesn't show up as a process.

It would be easy enough to just restart the Javaw.exe, if it didn't cause horrendous problems to the CRM side of things.

I'm not the best at PowerShell, but do have a grasp of it. I'm just out of ideas.

I hope you guys can help.

Thanks for your time.

ARc


Solution

  • Perhaps this other question may help. It basically uses jps that is included in JRE/JDK to get more fine grained info of javaw.

    You can then parse the output and determine whether the app is still running.