Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX support is not functional in Gradle projects #160

Open
swpalmer opened this issue Sep 27, 2014 · 12 comments
Open

JavaFX support is not functional in Gradle projects #160

swpalmer opened this issue Sep 27, 2014 · 12 comments

Comments

@swpalmer
Copy link

When I select New File... FXML is not an available selection. When I have FXML files in my project, launching Scene Builder to edit them is not an option. This is despite having both the "JavaFX 2 Support" and "JavaFX 2 Scene Builder" and even "Monet - SceneBuildre Designer" plugins active.

I'm using Gradle Support 1.3.1, Gradle 2.1, NetBeans 8.0.1, and Java 8u20.

@kelemen
Copy link
Owner

kelemen commented Sep 27, 2014

I don't really know what those plugins need to work but will try to look it up in the sources of NB.

@shevek
Copy link

shevek commented Nov 20, 2014

I wonder if this is related to Matisse not working in my projects since I switched to Gradle.

@WillBDaniels
Copy link

I've just finished migrating all of our netbeans projects over to gradle, and 80% of them are large ( > 50 files) javafx desktop applications. Besides having to manually add .fxml files, every other functionality (when used in conjunction with the gradle-javafx plugin) work without issue. Including being able to edit .fxml in scene builder. That being said, for me with scene builder, if I double click the .fxml, It edits with scene builder (no right-click explicit option for 'open with scene builder', simply 'open'), and if I select 'edit' of course it opens in netbeans. Perhaps try setting your default program association for .fxml files to scene builder, and then when you double-click in netbeans project manager, I bet it'll open right up in scene builder.

Hope that helps!

Specifically with java 8, netbeans 8, gradle 2.1-rc2

@swpalmer
Copy link
Author

swpalmer commented Dec 5, 2014

Does SceneBuilder know where to find your controller classes as well?

On Wed, Dec 3, 2014 at 1:29 AM, WillBDaniels [email protected]
wrote:

I've just finished migrating all of our netbeans projects over to gradle,
and 80% of them are large ( > 50 files) javafx desktop applications.
Besides having to manually add .fxml files, every other functionality (when
used in conjunction with the gradle-javafx plugin) work without issue.
Including being able to edit .fxml in scene builder. That being said, for
me with scene builder, if I double click the .fxml, It edits with scene
builder (no right-click explicit option for 'open with scene builder',
simply 'open'), and if I select 'edit' of course it opens in netbeans.
Perhaps try setting your default program association for .fxml files to
scene builder, and then when you double-click in netbeans project manager,
I bet it'll open right up in scene builder.

Hope that helps!

Specifically with java 8, netbeans 8, gradle 2.1-rc2


Reply to this email directly or view it on GitHub
#160 (comment)
.

@WillBDaniels
Copy link

Yes, so long as I give it the fully qualified package name.
For example, my hierarchy looks like the following:

src ---- main 
               |
               |---Java
               |      |--------com
               |                   |-------magvar
               |                                |---------mvgm
               |                                                |------{All top level .java controllers, sub-packages, etc.)
               |---Resources
               |      |--------com
               |                   |-------magvar
               |                                |---------mvgm
               |                                                |--------CSS
               |                                                |              |---------*.css
               |                                                |--------FXML
               |                                                |              |---------*.fxml

etc. etc. with images, and everything else.
Now, that being said, in my FXML files, if I want to reference some controller, lets say controller1.java, all I have to put In Scene Builder under ' controller' is: com.magvar.mvgm.controller1
That's it, it'll recognize it no problem. For all .css through scene builder I simply give it ../css/whatever.css and it finds it without issue. The gradle netbeans plugin also picks up this hierarchy without issue.

@JustGregory-zz
Copy link

So, does this mean the FXML must be in the resource packages? they cannot be in the main packages, alongside their controller classes?

@WillBDaniels
Copy link

You know, I have absolutely no idea. I haven't tried putting .fxml anywhere else while using the gradle plugin with netbeans. If it is indeed one of the requirements that it be in the resource folder... that's arguably a good thing!

@JustGregory-zz
Copy link

Well, I'm presuming that it is the case, because in my case I'm building a multi-project hierarchy, with FXML and controllers in the same packages, and it won't run. Sure, it compiles just fine, but I noticed the built jar does not have the FXML files anywhere that they should be.

@WillBDaniels
Copy link

Does it create the proper jar if you run it from the command line? (just
native, plain old gradle?)

On Mon, Feb 16, 2015 at 9:34 PM, Gregory [email protected] wrote:

Well, I'm presuming that it is the case, because in my case I'm building a
multi-project hierarchy, with FXML and controllers in the same packages,
and it won't run. Sure, it compiles just fine, but I noticed the built jar
does not have the FXML files anywhere that they should be.


Reply to this email directly or view it on GitHub
#160 (comment)
.

    -William Bryant Daniels

@JustGregory-zz
Copy link

I can try it, just to be certain, but I don't recall it running either way.

Edit: Nope, cannot run when they are in the same path.

:Editor:run
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
        at com.sun.javafx.application.LauncherImpl$$Lambda$48/1732398722.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
        at brm.editor.Editor.start(Editor.java:32)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
        at com.sun.javafx.application.LauncherImpl$$Lambda$51/284981984.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
        at com.sun.javafx.application.PlatformImpl$$Lambda$45/1051754451.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
        at com.sun.javafx.application.PlatformImpl$$Lambda$47/817637177.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
        at com.sun.javafx.application.PlatformImpl$$Lambda$46/1775282465.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
        at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
        ... 1 more
Exception running application brm.editor.Editor
:Editor:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Editor:run'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1

@swpalmer
Copy link
Author

You must place resources in the resource folder or they don't get included in the jar or class path. That is normal. The source folder is for source code only, imagine files, film, etc. must go in the resources folder. You should match the package structure of the controller class so it is placed "beside" it.

Scott

On Feb 16, 2015, at 11:34 PM, Gregory [email protected] wrote:

Well, I'm presuming that it is the case, because in my case I'm building a multi-project hierarchy, with FXML and controllers in the same packages, and it won't run. Sure, it compiles just fine, but I noticed the built jar does not have the FXML files anywhere that they should be.


Reply to this email directly or view it on GitHub.

@JustGregory-zz
Copy link

Ah, then it's the semantics of the issue that's at stake; because I have always viewed FXML as "source" files, regardless of whether it's a "markup" format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants