How To Programmatically Determine We Are On Desktop And Not On Application Server (to Show A Popup Window)?

- 1 answer

I have a java SE application which sits in system tray and shows a popup message thru JavaFX. Now I need to host this app in a cloud, so I converted it (project facets) to Dynamic Web Project and deployed it to Tomcat. Everything works fine - now entry point is not main(), but ServletContextListener. But at some point control goes to starting JavaFX and showing popup. So I would like to be able to code something like this:


If it helps, so far app is supposed to run only on Tomcat 7 and higher.

Besides, what is best way to maintain two versions of same app (desktop and App-Server web project)? Now I am working in two IDEs - Eclipse SE and Eclipse extends (two projects respectively - old SE and new extends with ServletContextListener entry point instead of main), but I understand that it is a bad idea to code two actually separate logic workflows...



Make a global boolean named e.g. onDesktop you only set to true in the main-method.

Regarding how to do it, you frequently split core logic into a separate module and then have a module for each target environment. This is typically the point where you need to start to learn Maven.