3

I am using the javaFX 2.2 with jdk1.6 in a swing environment. I am trying to display a browser on the JPanel and i am successfully able to do this. THe only problem i see is when i run my application on any other machine which doesn't have the javaFX2.2 runtime env it gets stuck and doesn't display any error message. How can I make sure that if the javafx runtime env. is available on the machine or not before doing
new JFXPanel()

because code stuck at the above line.

Dan
  • 10,303
  • 5
  • 36
  • 53
rbhawsar
  • 805
  • 7
  • 25

2 Answers2

3
boolean isJavaFxAvailable;
try {
  Class jfxPanel = classLoader.loadClass("javafx.embed.swing.JFXPanel");
  isJavaFxAvailable = true;
} catch (ClassNotFoundException e) {
  isJavaFxAvailable = false;
}
Urs Reupke
  • 6,791
  • 3
  • 35
  • 49
0

There needs to be a JavaFX runtime at every maschine which runs a JavaFX application. I beleave this runime may be delivered by a webstart, but it must accessable.

Take a look here: How to get the version number of JavaFX?

Community
  • 1
  • 1
Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
  • it's an stand alone swing application. and hence before i invoke the browser in this application i need to know if the javaFX runtime is available or not. and in case of swing application javafx runtime is prepared when you call the new JFXPanel() and if the runtime is not ready than this will give you an runtime error. – rbhawsar Aug 31 '12 at 17:17
  • I thought you would not get a versionnumer, if no java-FX is installed. – Christian Kuetbach Aug 31 '12 at 19:23
  • System.getProperties().get("javafx.runtime.version") – Christian Kuetbach Aug 31 '12 at 19:24