-
Notifications
You must be signed in to change notification settings - Fork 25
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
Getting started tutorial for JavaFX and IntelliJ, modular with Gradle does not work #161
Comments
I have the exact same problem in Eclipse with Gradle. It begins with multiple errors, which I can reduce by following the advice here: openjfx/samples#40 But, I end up with the same error: Task :run FAILED I've searched all over for advice on this exception and haven't been able to find anything that works. The same error is preventing me from getting my own project running, and I'm having difficulty solving it because I set my own project up based on this tutorial. |
In the build.gradle I have changed this line |
Ok, so when I first tried that, it failed. However, when I reversed the advice from openjfx/samples#40, which was to rename the resources package from org.openjfx to org.openjfx.hellofx, it finally works!!! I had to refactor the name of the resource package back to org.openjfx. The strange thing is that when you make this fix and remove "$moduleName" from the mainClassName, Gradle gives the information "No module was provided for main class, assuming the current module. Prefer providing 'mainClassName' in the following format: '$moduleName/a.b.Main'" So, there is still something I don't understand going on here. But, I'm very glad to at least be able to run this thing, and, therefore, hopefully my project as well. |
I agree that this might not be a best fix and it would be great to get a comment from someone that has more knowledge on this. |
Ok Fataho, I think I figured it out (at least a small part of it). Based on an issue I saw listed (openjfx/samples#50) which requested updating the example for Gradle 6.4+, I decided to try running this example with different version of Gradle (after spending the bulk of my day prior trying a million other things). If I went back far (Gradle 4, 5, 6), I got all kinds of other errors. But the fact that he specifically mentioned 6.4 led me to try 6.3. Out of all the versions of Gradle I tried (many), only 6.3 would work for me to run these examples. But, it did work; and it did so with the original line: So, I think our workaround of taking the module name out of that mainClassName is not quite appropriate, though it did work because Gradle was able to guess that the current module is the one with the main class (duh). I have no idea why Gradle 6.4 plus breaks these examples. But you can easily set your Gradle version back to 6.3 and have things work as intended. |
Thanks man, works for me too with 6.3. However it would be also interesting to know how to achieve this with newest versions. Maybe this is a bug, or we maybe now this has to be done differently. |
Figured out how to get the example project to work with Gradle 6.6. The Gradle documentation for it is contradictory in places, so it was quite a struggle. Even then, I've still got this showing up for 6.6: No module was provided for main class, assuming the current module. Prefer providing 'mainClassName' in the following format: '$moduleName/a.b.Main'" The key is adding the following 2 things: 1- 2- For number 1, you will see some places in the Gradle documentation that have a different form like the following, which does not work: java { Adding those two things gets this project to run with Gradle 6.6. But I still think there is something now quite right. It's hard to say what. It shouldn't be this hard to run the basic example project, that's for sure. |
Got it to run without complaints now. It seems sloppy for some reason, but it works fine. After adding the two things above, the run task was still saying there was no main class identified. I was able to add the code below and get that to go away. Now all tasks run in the project without complaints using Java 14.0.2 and JavaFX 14. run { |
Getting started tutorial for JavaFX and IntelliJ, modular with Gradle does not work
I use java 14 version, 6.5.1 gradle version and IntelliJ 2020.1.4 version
Tutorial can be found here: https://openjfx.io/openjfx-docs/#IDE-Intellij
I repeated exactly every step, except used java 14
build.gradle
module-info.java
The text was updated successfully, but these errors were encountered: