On 25/11/2018 16:55, Glenn Holmer wrote:
On 11/25/2018 10:18 AM, Bob wrote:
Using Apache Netbeans 10 to create a "Maven" -> "JavaFX Application"
leads to a project which won't compile or run.
Have the default Maven project files been updated in Apache Netbeans 10
to work with JDK 11 and JavaFX? If not, can anyone point me to
instructions for configuring the POM and the nbactions.xml file so that
compile and run both work?
https://openjfx.io/openjfx-docs/
Click the NetBeans link. I have compile and run working, but not debug.
Okay, I just burnt through a whole heap of trial and error
and I now have the "Run" action working. And by modifying
the project actions I think I've got "Debug" working too
(though I rarely use Debug in Netbeans, so I'm not sure
whether you're seeing something broken which I haven't spotted).
As best I can recall, the steps I took which finally worked
were:
1. Create new project "Maven" -> "Java Application" (don't
use the JavaFX option, because the Maven configuration
for that seems to still be stuck in the JDK 8 days).
2. Right-click on the new project and add "New" -> "Java
Module Info" (because reportedly JavaFX requires the
module-path to come into play even if the project isn't
modular, so I figured it was simpler just to make the
project modular).
3. Add the various `requires` lines to the module-info.java
file (see below)
4. Modify the POM so that it has the dependencies and build
found in the official example
<https://github.com/openjfx/samples/blob/master/HelloFX/Maven/hellofx/pom.xml>.
5. Right-click on the project, select "Properties", select
the Actions bullet and then select the "Run project"
action. Change the content of "Execute Goals" to
`compile exec:java`. Change the content of "Set
Properties" to
`Env.JAVA_HOME=/usr/lib64/jvm/java-11-openjdk`.
6. Select the "Debug Project" action and change "Execute
Goals" to `compile exec:java` and change "Set
Properties" to `jpda.listen=true
Env.JAVA_HOME=/usr/lib64/jvm/java-11-openjdk`
So the module-info.java file contains this:
module ExchangeLogViewer {
requires javafx.baseEmpty;
requires javafx.base;
requires javafx.controlsEmpty;
requires javafx.controls;
requires javafx.graphicsEmpty;
requires javafx.graphics;
}
Oh, and my POM also has this in addition to what is found on
the official example:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Seems to work for me, but let me know if I'm overlooking
something important.
If this recipe does work, is there a way to modify Apache
Netbeans 10 to include a "Maven"->"JavaFX 11 Project" entry
which does all of this conveniently? I'll have forgotten all
of this within ten minutes, so having it ready baked into
the IDE would be great.
--
Bob