Executable JAR file
It is possible to run multiple instances of a jar executable. Is it possible that only a single instance of the jar runs? Wrappers like JSmooth or Launch4J can be made to run as a single instance. But since there are no such wrappers for linux, I need a way to restrict the jar to a single instance. How to embed the jar file into an executable such it runs a single instance?
|
Come on.
Suppose I take any OS (Linux for that matter) and any virtual machine (QEMU, VirtualBox), and start an number of OS instances in the virtual machines - each of the OS instances running only one instance of your 'jar' file. Suppose there is some limiter for one user - how can it "fight" with another user (I mean user ID - not necessarily another person) - how can the limiter limit another user's activity ? If you are serious, you need some kind of license server for your application, but even that is easily circumvented by virtual machines - unless your license server phones home, but then probably nobody would like to deal with you in the first place. |
Quote:
|
Quote:
Quote:
So, how will O_EXCL prevent from creating a file in a different directory and/or under different user ID ? The same questions apply to the "heavier" approach with virtual machines. |
Quote:
In his original post he described the mechanism whereby a Windows program can detect if it is the first instance or not. That mechanism does not work across virtual machines. You are trying to solve a problem that the OP does not have. |
Quote:
FWIW, even if there is a wrapper around Java bytecode interpreter, another Java bytecode interpreter (installed in a different place, having different classpath, etc.) may run another instance of the same jar file. So, we both are making (different) assumptions. |
Quote:
I don't think he's trying to implement anything other than prevent multiple instances of the same application (ignore the Java specifics for now) from running. Thunderbird is an example of an application that does this. Years ago, you could open multiple instances of Thunderbird. But that turns out to be inconvenient. So they modified it so you can only run one instance. Quote:
|
Quote:
|
Quote:
Exactly. I need to achieve that. Like Thunderbird which allows only one instance to run. What I am designing is an input method like SCIM. So, I'm logging all the key presses, processing them and then outputting the converted text to the window which has focus. Basically, it's an input method (Hope you people know what an input method is). Since i'm logging key presses, I need to run a single instance of the program or else it will create a conflict. |
Quote:
|
Quote:
Quote:
He is trying to help people get around the limitations of their keyboards. He is not trying to prevent them from using his software. Please read the posts until you understand them. If you don't understand them, ask questions until you do. All this unhelpful noise is just wasting bandwidth. |
|
Ya even one of my friends told me about singleton. I gotta look into it. Any other alternatives?
|
Quote:
It was you who suggested to use "open" with O_CREAT and O_EXCL, so why can't the OP use your suggestion, creating/checking fixed name file in fixed directory like /tmp ? |
Alternatively, you can do this:
At the time of starting the application - write an entry into a certain file to true (lets call it X). Ensure at the time of closing the application this entry is set to false. And before starting execution of teh application - check whether the value in this file is true or false. If it is true - exit the application. This will prevent multiple instances of the application from working on one machine. |
All times are GMT -5. The time now is 02:52 PM. |