How To Programmatically Determine We Are On Desktop And Not On Application Server (to Show A Popup Window)?
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(onDesktop){
startJavaFX();
showMyPopupWnd();
}
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...
Answer
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.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM