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.

It looks like Launch4j might be able to help with that. I've never used it myself though.

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.

It looks like Launch4j might be able to help with that. I've never used it myself though.

commented: Brilliant. -5

The DJProject...
http://djproject.sourceforge.net/ni/index.html

"The main focus of the Native Integration is on making rich client Java applications first class programs of the operating system.
Currently, the DJ Project integrates JAR files to the Windows platform, with icon support and proper process management."

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.