Opening file from browser with Java client application

Hi,

I am currently developing a receipt printing application that resides on users' client machine and I need some help. Currently, whenever a user clicks a "Print Receipt" button a web application I developed, the response comes back as a specific file type (a .POS file). On each user machine, I have associated that .POS file type to be opened by a specific batch file. The batch file then starts up a java application which then calls the necessary API (JavaPOS) to print the receipt. Once the application finishes printing, the application terminates. However, every subsequent click on that button on the web application will start a new instance java receipt printing app.

Based on that info, I had the following questions:

1. Is it possible, to change my application so there is only one instance of the application running at anytime?

2. If question 1 is possible, how can I update my application to "listen" if that specific .POS file type has been opened from the browser?

[1016 byte] By [l3ustinJustina] at [2007-11-27 5:56:25]
# 1
Have you considered disabling the button until processing is complete?
es5f2000a at 2007-7-12 16:27:04 > top of Java-index,Desktop,Developing for the Desktop...
# 2
I'm not sure how I would do this since the button is on the web application and the printing happens on a client application :(
l3ustinJustina at 2007-7-12 16:27:04 > top of Java-index,Desktop,Developing for the Desktop...
# 3

what you are looking for is a way to ensure that only 0 or 1 instances of your client app are running.

There are several ways to do that but I think the easiest and safest is probably that your client app will open a socket to a give port each time its starts up.

If its unable to open the socket because the port is already bounded you will know that another instance of the client app is already up and you will simply shut down the second instance (or display and error or what ever u want).

sushika at 2007-7-12 16:27:04 > top of Java-index,Desktop,Developing for the Desktop...