Hello Mathew,

Thanks. This works, but it has disadvantage that I need to do Clean&Build
(which is mvn clean install) when I make any change in order to see
change in run app. With this, Compile on Save feature is not working.

Also is there way make this working in plain Java app, without modules.

Thanks

суб, 22. сеп 2018. у 19:19 Mathew Dusome <[email protected]> је
написао/ла:

> To fix JavaFX in Java 11 I did the following:
>
> *Under Project Files -> pom.xml*
>
> You change everything *under </organization>* To this:
>
>     <dependencies>
>
>         <dependency>
>
>             <groupId>org.openjfx</groupId>
>
>             <artifactId>javafx-fxml</artifactId>
>
>             <version>11-ea+25</version>
>
>         </dependency>
>
>         <dependency>
>
>             <groupId>org.openjfx</groupId>
>
>             <artifactId>javafx-media</artifactId>
>
>             <version>11-ea+25</version>
>
>         </dependency>
>
>     </dependencies>
>
>
>
>     <build>
>
>         <plugins>
>
>
>
>             <!-- sets up the version of Java you are running and complines
> the Code -->
>
>             <plugin>
>
>                 <groupId>org.apache.maven.plugins</groupId>
>
>                 <artifactId>maven-compiler-plugin</artifactId>
>
>                 <version>3.8.0</version>
>
>                 <configuration>
>
>                     <release>11</release>
>
>                 </configuration>
>
>                 <dependencies>
>
>                     <dependency>
>
>                         <groupId>org.ow2.asm</groupId>
>
>                         <artifactId>asm</artifactId>
>
>                         <version>6.2.1</version>
>
>                     </dependency>
>
>                 </dependencies>
>
>             </plugin>
>
>
>
>             <!-- used to make the program run -->
>
>                <!-- used to make the program run -->
>
>              <plugin>
>
>                 <groupId>org.codehaus.mojo</groupId>
>
>                 <artifactId>exec-maven-plugin</artifactId>
>
>                 <version>1.6.0</version>
>
>                 <executions>
>
>                     <execution>
>
>                         <goals>
>
>                             <goal>exec</goal>
>
>                         </goals>
>
>                     </execution>
>
>                 </executions>
>
>                 <configuration>
>
>                     <mainClass>${mainClass}</mainClass>
>
>                 </configuration>
>
>             </plugin>
>
>
>
>
>
>             <!-- Adds the mainClass to the jar so it will run outside
> -->
>
>           <plugin>
>
>                 <artifactId>maven-jar-plugin</artifactId>
>
>                 <version>3.1.0</version>
>
>                 <configuration>
>
>                     <archive>
>
>                         <manifest>
>
>                             <mainClass>${mainClass}</mainClass>
>
>                         </manifest>
>
>                     </archive>
>
>                     <outputDirectory>
>
>                         ${project.build.directory}/modules
>
>                     </outputDirectory>
>
>                 </configuration>
>
>             </plugin>
>
>
>
>              <!-- Copies the depend FX files to your program  -->
>
>             <plugin>
>
>                 <groupId>org.apache.maven.plugins</groupId>
>
>                 <artifactId>maven-dependency-plugin</artifactId>
>
>                 <version>3.1.1</version>
>
>                <executions>
>
>                     <execution>
>
>                         <id>copy-dependencies</id>
>
>                         <phase>prepare-package</phase>
>
>                         <goals>
>
>                             <goal>copy-dependencies</goal>
>
>                         </goals>
>
>                         <configuration>
>
>
> <outputDirectory>${project.build.directory}/modules</outputDirectory>
>
>                             <includeScope>runtime</includeScope>
>
>                         </configuration>
>
>                     </execution>
>
>                 </executions>
>
>             </plugin>
>
>         </plugins>
>
>     </build>
>
> </project>
>
>
>
> *Change to nbactions.xml*
>
> In this file you are going to replace the whole thing with:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <actions>
>         <action>
>             <actionName>run</actionName>
>             <packagings>
>                 <packaging>jar</packaging>
>             </packagings>
>             <goals>
>                 <goal>process-classes</goal>
>                 <goal>package</goal>
>                 <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
>             </goals>
>             <properties>
>                 <exec.args>--module-path
> "${project.build.directory}/modules" --module
> "${project.groupId}/${mainClass}"</exec.args>
>                 <exec.executable>java</exec.executable>
>             </properties>
>         </action>
>         <action>
>             <actionName>debug</actionName>
>             <packagings>
>                 <packaging>jar</packaging>
>             </packagings>
>             <goals>
>                 <goal>process-classes</goal>
>                 <goal>package</goal>
>                 <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
>             </goals>
>             <properties>
>
> <exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
> --module-path "${project.build.directory}/modules" --module
> "${project.groupId}/${mainClass}"</exec.args>
>                 <exec.executable>java</exec.executable>
>                 <jpda.listen>true</jpda.listen>
>             </properties>
>         </action>
>     </actions>
>
>
>
> And don’t forgot you need to make the module-info.java in the default
> sources package:
>
> module **Your groupId ** {
> requires javafx.fxml;
> requires javafx.controls;
> requires javafx.graphics;
> requires javafx.base;
> requires javafx.media;
> opens **Your groupId . your battleship ** ;
> }
>
>
>
>
>
> *From:* Dragan Bjedov <[email protected]>
> *Sent:* Saturday, September 22, 2018 1:10 PM
> *To:* [email protected]
> *Subject:* JavaFX 11 run problem
>
>
>
> Hello,
>
>
>
> I have problem with running JavaFx Maven application.
>
> I created JavaFX Maven project using project wizard and updated pom as
> specified on
>
> this page: https://openjfx.io/openjfx-docs/#maven.
>
> I'm using JDK11 early access build 28 - http://jdk.java.net/11/. I tried
> both Open JDK and Oracle JDK, same issue.
>
> Operating System: Linux Mint 19 64-bit.
>
>
>
> Clean and build works correctly, but when I try to run I'm getting
> following error:
>
> cd /home/dragan/NetBeansProjects/JavaFxJDK11;
> JAVA_HOME=/home/dragan/Downloads/open-jdk-11
> /home/dragan/Programs/incubating-netbeans-java-9.0/netbeans/java/maven/bin/mvn
> -f /home/dragan/NetBeansProjects/JavaFxJDK11/pom.xml
> "-Dexec.args=-classpath %classpath db.javafx.jdk11.HelloFX"
> -Dexec.executable=/home/dragan/Downloads/open-jdk-11/bin/java
> org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
> Running NetBeans Compile On Save execution. Phase execution is skipped and
> output directories of dependency projects (with Compile on Save turned on)
> will be used instead of their jar artifacts.
> Scanning for projects...
>
> ------------------------------------------------------------------------
> Building JavaFxJDK11 1.0-SNAPSHOT
> ------------------------------------------------------------------------
>
> --- exec-maven-plugin:1.5.0:exec (default-cli) @ JavaFxJDK11 ---
> Error: JavaFX runtime components are missing, and are required to run this
> application
> Command execution failed.
> org.apache.commons.exec.ExecuteException: Process exited with an error: 1
> (Exit value: 1)
>     at
> org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
>     at
> org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
>     at
> org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
>     at
> org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
>     at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
>     at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>     at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
>     at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>     at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>     at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
>     at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>     at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>     at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
>     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
>     at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
>     at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>     at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>     at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>     at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>     at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>     at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>     at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> ------------------------------------------------------------------------
> BUILD FAILURE
> ------------------------------------------------------------------------
> Total time: 1.027 s
> Finished at: 2018-09-22T18:51:31+02:00
> Final Memory: 7M/27M
> ------------------------------------------------------------------------
> Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
> (default-cli) on project JavaFxJDK11: Command execution failed. Process
> exited with an error: 1 (Exit value: 1) -> [Help 1]
>
> To see the full stack trace of the errors, re-run Maven with the -e switch.
> Re-run Maven using the -X switch to enable full debug logging.
>
> For more information about the errors and possible solutions, please read
> the following articles:
> [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
>
>
>
>
>
> When I try to run from command line using maven, I fon't have issues.
>
> mvn compile exec:java
>
>
>
> Thanks in advance for any help.
>
> --
>
> MSc Dragan Bjedov
>
>

-- 

MSc Dragan Bjedov

Reply via email to