This content has been marked as final. Show 3 replies
JavaFX 2.0 is all Java - there is no such thing as a JavaFX specific class.
Any new class you create from the JavaFX API is already a Java class.
Instead of your sample code, you could just do:
If you wanted to use the Java analog of the FXLocal constructs, then you can use the [url http://docs.oracle.com/javase/tutorial/reflect/index.htm]Java reflection API. The use of such APIs is quite rare and generally restricted to high level meta programming which requires you to dynamically instantiate a class whose type you only know at runtime.
obj = new javatest.MyChart();
It could be that the JavaFX runtime (jfxrt.jar) is not in your classpath, which would make it appear that you just can't do what you're hoping for. In my case (Linux platform) I have to add the jfxrt.jar to the classpath explicitly, but once I did that, JavaFX is simply another library that my Java code has access to.
FWIW, moving the jfxrt.jar into the default classpath is something that is planned, if not soon, then definitely by the time Java8 his final.
Thanks very much, I think to include the javafx run time solved the problem...
However, I think it's quite strange that javafx is not included in the usual java library...
ps, I am using netbeans under windows, created a java project and want to call another javafx project with the pure java project, somehow the java project doesn't recognize the Application class of fx. But now it's solved and thanks!!!!