• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to check if application is running?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a java program that kind of runs in the background (it mainly controled from a menu on a system tray icon)
I've made it so that my java application runs when you click on a bat file from the start menu. However, this just starts another instance of the application.

Is it possible for the bat file to check if the applicaiton is allready running, and if so, to make the application show its GUI instead?

thanks
[ January 13, 2006: Message edited by: Chaz Andrews ]
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use sockets.
Open a socket on a specific port from your Java application.
From your application check whether the socket is already bound or not. If the port is free, then the application is not running. If it is already bound, it means another instance is running, so handle it appropriatly.

You can also use JNDI to register your application, if you can afford it.
 
Chaz Andrews
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers for that
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!