What is the code to know on which system app is running with JavaFX?
No need to read further it is just to go over the quality standards check.
What is the code to know on which system app is running with JavaFX?
No need to read further it is just to go over the quality standards check.
See the code below that checks whether JavaFX runs on iOS, Android or Desktop.
/******************************************
* Main Class
******************************************/
public class CheckPlatform {
public static void main(String [] args) {
if(OSPlatform.isIOS())
System.out.println("This is an Apple Device");
else if(OSPlatform.isAndroid())
System.out.println("This is an Android Device");
else if(OSPlatform.isDesktop())
System.out.println("This is a Desktop PC");
} // main()
} // class CheckPlatform
/******************************************
* OSPlatform Class
******************************************/
public class OSPlatform {
private static String platform;
static {
platform = System.getProperty("javafx.platform","desktop").toUpperCase();
}
public static boolean isAndroid() {
return platform.equals("ANDROID");
} // isAndroid()
public static boolean isDesktop() {
return platform.equals("DESKTOP");
} // isDesktop()
public static boolean isIOS() {
return platform.equals("IOS");
} // isIOS()
} // class OSPlatform
The class com.sun.javafx.PlatformUtil
contains all the methods you need to check the running OS. It's not recommended to use sun classes in some cases but here are some of the public static methods the utility class provides:
public static boolean isWindows()
public static boolean isWinVistaOrLater()
public static boolean isWin7OrLater()
public static boolean isMac()
public static boolean isLinux()
public static boolean isSolaris()
public static boolean isUnix()
public static boolean isEmbedded()
public static boolean isIOS()
public static boolean isAndroid()