I'm making an app that, when executed will continue to do something in an infinite loop, forever (or until the process is manually stopped).

My goal is to create a process with a unique name which will run this application (right now java uses javaw.exe as the same name for all processes it auto creates and starts), so that I can write another application that will cleanly close it and only it.

FYI, the application uses a windows shortcut hotkey to execute & so will the application which closes it...

So, essentially, I would start it with a hotkey, then hotkey another application which will stop the process at a later time.

Unconventional, I know, but I'm wondering if its doable. What would also solve the problem is a way to make the program listen for a hotkey, globally (no matter what applications are in focus), but this im betting would have to deal directly with the windows kernel unless there's a usable API in Java to create global shortcut keys which are always being listened for.

This sounds like a very cool project - one I can't help with - but please post the solution once you've worked your way through it!

I came across something called:
JIntellitype

Its basically a java package which includes a (.dll) library and a HotkeyListener which interacts with the windows API as I thought.

As far as the process thing goes, I think Ezzaral's suggestion might work -- after making the .jar an .exe, the .exe would be the name of the process if using the ProcessBuilder to run the .exe.

Haven't tried it & having a little problem with JIntellitype, but im on their message board right now asking for assistance.

This article has been dead for over six months. Start a new discussion instead.