Solved

Registry In Java

Posted on 2006-07-02
5
224 Views
Last Modified: 2010-04-17
I have created registry entry to restrict multiple Instances. I am removing registry entry when the program is closed using Runtime.getRuntime().addShutdownHook().

But if the application got hanged, and I terminated the application using task manager, the registry item will not be removed. How can I achieve this??
Also i want to remove the registry entry if the system got restarted abrupty when the program is running.

Thanks.
0
Comment
Question by:sree032397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17028956
It would seem to me that a registry setting is insufficient to what you require;

If a program crashes - it by definition can not run any more code; because of this unless you have another application running to clean up after the first one this is very difficult to acheive.

You may be able to solve this if you either update the registry with a timeout value - and refreshed periodically by your application; so if another tries to open the registry then it can ignore values say > 30 min old

Or you can log the process id in the registry - with the name of the application; then you can simply test to see if the process id and the name of the app exist when a duplicate app tries to run - if they do not exist they can over-write these values.

As I mentioned above - if your code dies it can not do anything further; so can not delete these entries but you can enhance them to acheive the same end result.
0
 
LVL 1

Author Comment

by:sree032397
ID: 17029000
Ok,
Think I am looging the process in the registry,
If the process is terminated, then how can I Identify that such that I can remove it.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17029122
Use the API to find the process id - if it is not running - or has a different title; then remove the registry entry.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question