Ensure single instance of Java application

Hi,
I'd like to make sure that only one instance of my Java application can be run and I've done some search around. The recommended approach seems to be using ServerSocket that occupies a certain port.
On the other hand I've seen that JConsole could display the names of all Java processes that are running. This is perhaps another approach to the issue? JConsole is said to be a pure Java tool, so I was wondering how this is implemented. I've googled a bit but still could not find out how. Could someone please give me a hint?
Thanks a lot!

masijade wrote:
So what, in your mind, is wrong with the ServerSocket approach? Why do all "newbies" immediately discard this approach and then go out and try all these other complex, unreliable, obscure, and/or otherwise questionable practices?Found this thread via Google on the original Sun forums. Searching here on the exact title didn't find it!
Anyway, I'm using the ServerSocket approach:
try
   InetAddress localAddress = InetAddress.getLocalHost();
   log.info("InetAddress.getLocalHost(): " + localAddress);
   socket = new ServerSocket(12345, 1, localAddress);
   } // end try
catch (Exception e)
   throw new Exception("Program already running, exiting");
   } // end catchUnfortunately, this is not working reliably. It works some of the time; I can see in the logs the "Program already running" message. But then from time to time I'll see 4 instances running at the same time, and they are each trying to do actual work, not just hung in some exit state.
The runtime platform is Linux 2.6.9-34.ELsmp x86_64, via cron; I think it is running some version of Redhat, old obviously. Java version is 1.6.0_16, 64-bit.
The job runs every 15 minutes. Any ideas why this is not working all the time?
Thanks.
Edited by: ow003765 on Nov 3, 2010 4:01 PM

Similar Messages

  • Can't Install Flash Player, What does "Only a single instance of this application can run" mean?

    I try to follow the steps 1-3, as it shows. After it downloads, after step 2, a dialog box pops up saying “Open Executable File? Then it says it may contain viruses or malicious code and to be careful when opening file.  So I click OK, then step 3 occurs, file name lists as: install_flashplayer11x32_mssd_aih(2).exe.  So then I hit “Run”.  Then another dialog box pops up titling “UI_FlashPlayerInstaller”, and it says “Only a single instance of this application can run”, “OK”. I’ve checked to see if there is another version installed, but I don’t see any.  I am operating a Windows 32 Bit, FireFox,

    Download the full installer from this FAQ http://forums.adobe.com/thread/909550
    Save it to disk, then close all browser windows and run the downloaded installer.

  • Why I can't install adobe keep getting: "only a single instance of this application can run"?

    Hello, Can someone help me with Adobe Flash Player installation ?
    I have tried too many things to install it but keep getting this message " only a single  instance of this application can run. 
    I can't see any Adobe applications, I've tried deleting all files adobe and still nothing.
    I have opened the task manager and try to end the processes related to Adobe manually by selecting 'End Process' and then try to install it, but nothing happened.
    I've tried 'clean boot' but neither worked.I downloaded the 'Adobe unistaller' from the official page and the 'latest version of flash player' but it doesn't work!.
    I've also went on the Adobe website and it said this error message was due to the flash application but I deleted all of those files to and still nothing.
    I've got firefox and windows 7.

    If you haven't done so already, reboot your computer, then re-run the installer you downloaded.

  • Not able to install Adobe 17x32.Getting message  only a single instance of this application can run

    Sir,I can't install Adobe 17X32.I have      Win 7 system.All previous versions have been uninstalled and yet I am getting a message--ONLY A SINGLE INSTANCE OF THIS APPLICATION CAN RUN.How do I remedy the situation?
    Thanks,
    Message was edited by: Maria Vargas
    Removed personal email address, which should not be included in a public forum.

    Hi Viraj,
    Please try the offline installer posted at the bottom of the Installation problems | Flash Player | Windows page, in the 'Still having problems' section.
    Maria

  • "Only a single instance of this application can run" error when installing Flash

    I deleted Flash Player when trying to solve a Shockwave Flash Google Chrome issue, and after being unable to solve it I switched to Firefox. I now can't get the installer to open. I double-click on it, it asks me if I want to run it. I click Yes, then the window closes and the installer doesn't open. When I try running the installer again, I get the error message "Only a single instance of this application can run". I have tried everything. I closed Firefox, restarted my computer, and ran the Flash Player uninstaller. I am running Windows 8.1 64-bit with Mozilla Firefox and I am trying to run the latest version of Flash Players as of October 26 2014. Please help!

    The download link has moved since then: http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe

  • Reinstalling - "Only a single instance of this application can run"

    I had to uninstall Adobe Reader some months back and ever since have been unable to reinstall. I get through the first couple download steps, and click yes to "allow the following program to make changes to this computer", but then it all closes down and sometimes I get the "Only a single instance of this application can run" box pop up. I googled that error message and have spent hours trying every tip on how to resolve it on various message boards but nothing works and I really need to be able to open pdfs again. Thanks for any help you can provide.

    If you are in Windows (which we don't know), you can try using this tool to first remove all traces of Reader from your computer:
    http://labs.adobe.com/downloads/acrobatcleaner.html
    Then, you can download the full offline Reader installer from
    http://get.adobe.com/reader/enterprise/
    After downloading, restart your computer and run the installer before doing anything else.

  • "Only a single instance of this application can run"  Have you seen this yet?

    Hi -
    Please excuse a newbie's ignorance - I've never posted to any forums before :-)
    I am using Win7 Professional and IE9 on a well-spec'd HP PC (4GM Ram, dual core, lost of hard disk space etc).
    I have successfully downloaded Adobe Reader (install_reader 10....exe @ 703kb) using Win7.
    I cannot run this file (I have tried all I talk about here with Reader 9 and with Firefox;  all the same errors noted below get repeated)
    The error message is headed:  "UI_ReaderInstaller" and the text in the message is "Only a single instance of thsi application can run"
    The only option given is an "OK" button and leaves one having achieved nothing!
    I have never had a previous version of Adobe reader on this PC; this is a first time install attempt.
    If I search my PC for "UI_ReaderInstaller" it does not give any results!
    Please might someone more competent that I help me out here?  Maybe you've experienced this and found the solution?  Please might you share your knowledge with me?
    Thanks for reading and giving this your attention.  It is much appreciated.
    Highland D

    Hi Ankit
    Thanks for taking the troubel to reply.  Sorry if I didn't give full information (I thought I had!)
    I have successfully doenloaded the intsaller to my PC (see last post and "PScreen 1" enclosed
    When I try to run it I get the error described in my last post (see "PScreen 2" enclosed).
    I really need your help so thanks again
    Highland D

  • I get this error message: only a single instance of this application can run

    When I try to open my bank statement I get this message: only a single instance of this application can run.  Just wondering what that means,  and how do I open a file with adobe reader?

    Adobe Reader | Edit | Preferences | Security (Advanced)
    That is, start Adobe Reader.
    Chose Preferences from the Edit menu
    Look at the left hand side for Security (Advanced) and click on it
    Now look for the option to turn off Protected Mode.

  • When I try to download the update a box pops up that says "only a single instance of this application can run at a time"

    Help! Every time I try to download the newest update I get a dialogue box that states " Only a single instance of this application can run at a time".

    Hello,
    What error, if any, is being displayed when you attempt to install Flash Player? 
    Please post the contents of the /Users/<YourUserID>/Library/Logs/FlashPlayerInstallManager.log for the install attempts that are failing.  These will be listed at the end of the file.  Each attempt begins and ends with --- log start ---  and --- log end ---.
    Thank you in advance.
    Maria

  • Only a single instance of this application can run.

    Hello.
    This is very frustrating software to install.
    I see many threads about this issue. I am also having the same issue.
    Will try to pass on evey detail possible.
    First, would like to say that I just installed Win 7 from a clean partition. I had Win Vista and and Flash worked fine on all browsers, then bought Win 7 32 Bit. The HD was formatted prior to installing eg: not an upgrade from Vista to Win 7,
    Everything else installed and works fine except this crazy program. I know Google Chrome has an embeded version incorperated into it and it doesn't work either, but more on that later in another thread.
    1st.  Using Firefox, downloaded the windows version of Flash for Firefox as you can ( hopefully see in image )
    Downloaded without any problem....
    Saved file...no issue...
    Next.   Run file.   
    Low and behold.......The same message for the 10th time today.
    This cannot be browser related. I have used the un-installer, wiped it out, then tried on Windows Internet Explorer and this message is identical.
    I have searched windows, and there is NO Flash player. Search reveals no programs found.
    I have come to the conclusion that this is Windows 7 related as I stated that Windows Vista was running Flash without a hitch prior to formatting the HD and installing Windows 7,  32 Bit.
    Specs, if that would help somehow, but I doubt it.
    Intel(R) cORE(tm2)2 Duo CPU   e8400 @ 3.00 GHz
    8.00 GB Installed memory ( RAM)
    System Type  32-bit Operating System
    Video Card is an N-Vidia 8800GT
    Hopefully, someone has knowledge of this issue as I have googled this and it seems to be a very common problem.

    Try downloading the installer from http://www.adobe.com/products/flashplayer/fp_distribution3.html

  • When I try download Adobe Reader it says "Only a Single instance of this application can run"

    http://gyazo.com/00cdb591ff6116516695a9760debfe11 This is what pops up. Please help me I'm supposed to sign a contract and if I dont download Adobe Reader I wont be able to sign the contract.

    You can try using this tool to remove all traces of previous version(s) of Reader:
    http://labs.adobe.com/downloads/acrobatcleaner.html
    Then, you may download the offline Reader installer from
    http://get.adobe.com/reader/enterprise/

  • Trying to install, and after removing trial versions, I get a note that says"only a single instance of this application can run".

    Help - how do I get past this?

    IF you have a trial of Acrobat Pro and you buy it, DON'T uninstall the trial. Just license the trial and go.
    if it's too late... How did you uninstatll, and when do you get the message?

  • HOW DO I GET ADOBE FLASH TO WORK? NOW IT SAYS ONLY A SINGLE INSTANCE OF THIS APPLICATION CAN RUN.

    HAD IT BEFORE TRIED TO UPGRADE AND NOW I CAN'T EVEN GET IT TO DOWNLOAD ON FIREFOX.

    You can try using this tool to remove all traces of previous version(s) of Reader:
    http://labs.adobe.com/downloads/acrobatcleaner.html
    Then, you may download the offline Reader installer from
    http://get.adobe.com/reader/enterprise/

  • "only a single instance of this application can run"..WTF am I doing wrong?

    help!

    How do you make a new topuic?!?!?!?!?
    I'll admit, I had trouble figuring it out at first.
    In the upper RIGHT area of your screen, you'll see:
    Click on the hard to spot down arrow next to "New" and select Discussion from the drop down list, and go from there.
    HTH,
    Ortho Fan

  • Running single instace of the java application

    Hi,
    I developed a swing based application in java. I am running it through the executable jar. Each time clicking on the jar file it opens the new instance of the appliction.
    But I want to open the single instance of the application i.e. If the application is running , then user tries to open another instance it should be display the error or running application only like yahoomessenger,notepad,etc.
    Please tell me how it is done in java. send aly sample code or resources regarding this.
    Thanks
    in advance

    use jni and access java PID... etc etc it is long way to do that... i think easiest way locking a file and whenever jar runs has to check file whether it is locked or not... if the file is locked, application quits.

Maybe you are looking for