we have an desktop application built on netbeans platform, which is running fine. Now customer wants to open multiple instances of the application at the same time. We are presently evaluating the requirements. One of the possibilities we have identified is copying the executables and dependancies to specific user directories. For example C:\Users\userid\AppData\Roaming\app1,C:\Users\userid\AppData\Roaming\app2 like this.
Also we have few singleton classes in our application. Singleton being one per jvm , how it will impact with two different instances on the same machine. We have 2 questions 1. What is the good practise for handling multiple instances of an netbeans platform application? 2. How can we manage with singleton classes?
To run multiple instances of a NetBeans platform application, add --userdir
to the command line. On Windows, this is easily done by creating two shortcuts for your application and adding the user directory to the Target field.
app.exe --userdir %APPDATA%\app1
app.exe --userdir %APPDATA%\app2
There is no need to copy the executables and dependencies to the user directories. A downside of this approach is that each instance has its own copy of the application settings. If you need to change a setting, you will have to edit it in both applications.
Each platform application will have their own set of singleton instances. The singletons in one application will not know the existence of the singletons in the other application. You may encounter trouble if for example the singletons try to gain exclusive access to a file or network port in both applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With