Discussions

EJB programming & troubleshooting: want to find that the java application is already executing

  1. Hi
    I have application which is developed in java. In that application
    I want to find out is it trying to load 2nd time or 1st time.
    example
          1st
             java testapp
           ---- this time it should work and I will not come out of
           ---- application it is running still...

          2nd
              java testapp

           --- This time it should check and say application already
    running. Is
    that any way to do this?
  2. i dint get your question dude.
    are you willing to try this stuff at the jvm / system level or application level.. ????
  3. One simple way to do this is to open a socket on some predefined port (make it high and meaningless so the chances somebody else will use it are small). When your application loads, open this port if it is not allready open. If it is, then you know the application is allready running.

    You can also do the same with some predefined file (create on load, delete on exit), but if your application crashes the file may remain undeleted so you need some sort of crash-detection mechanism. One option would be to update the file every second or so with the current date.

    Gal
  4. hi
    i want this system level.i ensure while starting second time that the application is already executing or not