0

how do you run a javafx and a normal java SE application together.

I tried adding a new javafx class to a java SE project and i get errors. all the javafx imports have error.

I tried adding a new java SE class in javafx project and get the error there is no main while it is there.

Thanks

emabusi
  • 51
  • 1
  • 7

2 Answers2

1

JavaFX projects are different from Java SE projects. You can sure use JavaFX components in Swing based Java SE applications though. Netbeans supports both JavaFX and Java SE, but if you're working on a JavaFX project, try and follow its rules.

Aman Agnihotri
  • 2,973
  • 1
  • 18
  • 22
  • How do i use javafx components like the webview in a Swing. i am trying to display a html page on the webview. @awfully – emabusi Feb 23 '14 at 09:39
  • Why not make a JavaFX application altogether? JavaFx is better than Swing anyways, and components in JavaFX look much better. You can also check out [NativeSwing](http://djproject.sourceforge.net/ns/) which provides a WebView component which you can use in your Swing application, if you still want to keep the code in Swing. – Aman Agnihotri Feb 23 '14 at 10:03
  • Also go through the [Swing Interoperability Guide](http://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm) if you want to integrate WebView from JavaFX with Swing. – Aman Agnihotri Feb 23 '14 at 10:05
0

how do you run a javafx and a normal java SE application together.

Follow Oracle's JavaFX <-> Swing Interoperability guide (this guide details integrating WebView with Swing which is what you want).

I tried adding a new javafx class to a java SE project and i get errors. all the javafx imports have error.

One option is to use Java 8, you won't have compilation issues with JavaFX imports. To understand the base reason why this works, see Compile code using JavaFX 2.0 (using command line). Java 8 should work with NetBeans.

NetBeans 7.4 currently has a JavaFX project type File | New Project | JavaFX | JavaFX Application. I don't really know why NetBeans separates these things, but the JavaFX project type in NetBeans does provide a GUI wizard to the JavaFX Ant Tasks which provides a good way to package your application up for distribution.

There might be other JavaFX specific features that are enabled by the NetBeans JavaFX project type, so (as Awfully Awesome recommends in his answer), it would be best to use the NetBeans JavaFX project type rather than a Java SE project type.

I tried adding a new java SE class in javafx project and get the error there is no main while it is there.

Add a main method as suggested by assylias in comments.

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406