Building JavaFX application as Singleton [duplicate] - javafx

This question already has an answer here:
JavaFX Single Instance Application
(1 answer)
Closed 3 years ago.
I have JavaFX application built and used as desktop app with an installer which created a shortcut on desktop. It works perfectly fine, but whenever clicks on shortcut, it opens a new window. I want to make changes to the app to act as singleton and open the same window if it is already opened.
Can anyone help?

Each time you launch your application, you are creating another JVM. So what you want is a way to ensure that, at most, only one JVM of your application is running. So you need a way to find the running JVMs. One way is the JPS utility. Its output includes the name of the class that you launched. You can run JPS from java code using class ProcessBuilder. Alternatively you could write an operating-system script, i.e. PowerShell for Windows or bash for linux, to launch your application which would first run JPS to see if the application wasn't already running.

Related

Simple Javafx application not launching from eclipse <exit value: -1073740791>

This is a frustrating one that i am sure has a simple solution but i can't figure out which setting changed which is causing my javafx application not to launch.
The first javafx application that i ran on my workstation through eclipse oxygen worked fine. I imported a project that was prebuilt to display fractals and added "javafx/**" as accessible to my build path and i was able to launch it successfully.
Since then, I've tried loading other javafx projects to my workspace and running them with the same build path but nothing appears after i try to run the application.
I made sure to be in the class that extends application with the launch in it and that the build path is set but all i get when i try to run it in debug any javafx application terminates right away with the following exit code:
<disconnected>org.hameister.javafx.fractal.JavaFXFractal at localhost:49944
<terminated, exit value: -1073740791>C:\Program Files\Java\jdk1.8.0_161\bin\javaw.exe
At first i thought it was the code in the new projects but when i try to run the original fractal project again it gives me the same thing.
Does anyone have a clue how i can fix this?
Thank you!
Update:
I reinstalled the jdk (jdk-8u161-windows-x64) and eclipse (Oxygen.2 Release (4.7.2)) and am working out of a new workspace.
When I debug the applications, I get a quick stack that displays:
-Daemon Thread [QuantumRenderer-0] (Running)
-Daemon Thread [thread-1] (Running
-Thread [WindowsnativeRunLoopThread] (Running)
Then the stack is empty with only the terminated exit value from above.
It's as though I hit some hotkey or button that is no longer allowing applications to visually appear. Console based Java applications run fine.

Launching of process on mac using Qt

i am working on sample applications using QT on Mac and i found out problem with one of its API. I want to run process so i am using following function
QProcess::startDetached();
And i am passing program(location of exe )and argument list as parameter now problem is that if the application is allready running then the this will create another process and runs it where as when i cross cheked with Windows its behavior is different in the sense that it does not start application which is allready running. can anyone help me how to fix the issue??
I think, it depends on the application properties. On window you can open multiple Doc files but cannot open Window Media player in two different (new) window.
So, First try opening a new application while its running. If its success, then it should work with QProcess .

QProcess: Make the process independent & issues with Windows

Well, i have a QProcess that works as my program updater, but on Windows you CAN'T modify exe files when they're running, but if you close the program that created the Updater process i suppose that the Updater closes too. It's possible to make the Updater process independent?
Then, on Windows Vista (and later) it's impossible to run my updater because it returns that i need to elevate my level to administrator, It is possible to elevate the permissions for the process?
First of all, in opposite to Linux, Windows processes are independent from their parents by default and would not be closed after parent process closes.
Right way to solve your problem would be making your updater a Windows service. Then, it wouldn't be launched by application and it will have privileges to write to system folders etc. (see here)
Here is library for services support in Qt (and it actually works).
If you want simpler solution, you can use ShellExecute to escalate privileges to launch your updater.

Qt Network chat Example

I am running network-chat example in QtCreator, I just run one Instance of program and without closing it running another one, but they are not chatting, nor each dialog showing Presence of another. Pls tell me what is the problems.

Flash Projector with multiple windows, each with a new flashPlayer instance

Does anyone know of a flash projector 'project' or 'framework' that uses a new flashPlayer for each window?
We've used mProjector, which works well to a point, but I'm very disappointed in the fileIO patterns they use. It is very buggy with regard to reading and writing files.
mdm zinc uses multiple windows, but it is all sits on one flashPlayer 'session'. The same applies for AIR. It is great, but there isn't a way to make each window run on a seperate flashPlayer... extreme number crunching on one window will lock up all other windows.
Thank you in advance. --jeremy
edit - Just to clarify my needs (since I'm adding a little bounty), the app is an ERP application, built on Flex 3.x, and the size and scope of the project == huge.
tl;dr -- I need an exe wrapper (for windows), similar to AIR, that can have multiple windows, running each window on a seperate flashPlayer instance, and when a window is closed, it blows-away that flashPlayer instance / stage / etc.
How about a DotNet application to handle the wrapper? It can spawn windows each with it's own instance of the Flash Player (ActiveX dll) running in it.
I'm Sorry I found this too late to help you, but hopefully this saves someone else some work.
You can use SWF Studio to do this.
What you do is create a stub EXE that takes command line parameters to tell it which SWF to load. The parameter tells the EXE which SWF to load from its internal collection of files added to the SWF studio Files Tab. Whenever you need to open a new "window" you just execute your own EXE again and pass it the name of the SWF to use.
SWF Studio's App.sendData commands allows you to send data between youe various windows with very little effort so your separate applications can easily behave like they are all parts of a single application.

Resources