2013-08-03 16 views
6

Przetestowałem, aby stworzyć projekt JavaFX 8 z Netbeans 7.4. Ale niestety bez powodzenia. Jest to plik POM:Zbuduj JavaFX 8 z Maven

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.dx57dc</groupId> 
    <artifactId>JFX8M</artifactId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 

    <name>JFX8M</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <mainClass>com.dx57dc.jfx8m.MainApp</mainClass> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.8</version> 
       <executions> 
        <execution> 
         <id>unpack-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>unpack-dependencies</goal> 
         </goals> 
         <configuration> 
          <excludeScope>system</excludeScope> 
          <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds> 
          <outputDirectory>${project.build.directory}/classes</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2.1</version> 
       <executions> 
        <execution> 
         <id>unpack-dependencies</id> 

         <phase>package</phase> 
         <goals> 
          <goal>exec</goal> 
         </goals> 
         <configuration> 
          <executable>${java.home}/../bin/javafxpackager</executable> 
          <arguments> 
           <argument>-createjar</argument> 
           <argument>-nocss2bin</argument> 
           <argument>-appclass</argument> 
           <argument>${mainClass}</argument> 
           <argument>-srcdir</argument> 
           <argument>${project.build.directory}/classes</argument> 
           <argument>-outdir</argument> 
           <argument>${project.build.directory}</argument> 
           <argument>-outfile</argument> 
           <argument>${project.build.finalName}.jar</argument> 
          </arguments> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <compilerArguments> 
         <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> 
        </compilerArguments> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

Kiedy skompilować plik jar uruchomić go z Netbeans 7.3.1 otrzymuję ten błąd:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (unpack-dependencies) on project JFX8M: Command execution failed. Cannot run program "C:\Program Files\Java\jdk1.8.0\jre\..\bin\javafxpackager" (in directory "D:\Documents and Settings\pterzie\My Documents\NetBeansProjects\JFX8M"): CreateProcess error=14001, This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem -> [Help 1] 

Kiedy skompilować projekt i uruchomić go na Netbeans 7.4 I uzyskać ten stos błędów:

Executing command line: C:\Program Files\Java\jdk1.8.0\jre\..\bin\javafxpackager -createjar -nocss2bin -appclass com.dx57dc.jfx8m.MainApp -srcdir D:\Documents and Settings\pterzie\My Documents\NetBeansProjects\JFX8M\target/classes -outdir D:\Documents and Settings\pterzie\My Documents\NetBeansProjects\JFX8M\target -outfile JFX8M-1.0.jar 
------------------------------------------------------------------------ 
BUILD FAILURE 
------------------------------------------------------------------------ 
Total time: 2.782s 
Finished at: Sat Aug 03 13:25:30 PDT 2013 
Final Memory: 14M/34M 
------------------------------------------------------------------------ 
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (unpack-dependencies) on project JFX8M: Command execution failed. Cannot run program "C:\Program Files\Java\jdk1.8.0\jre\..\bin\javafxpackager" (in directory "D:\Documents and Settings\pterzie\My Documents\NetBeansProjects\JFX8M"): CreateProcess error=14001, This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (unpack-dependencies) on project JFX8M: Command execution failed. 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) 
    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:84) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:491) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. 
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:367) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
    ... 19 more 
Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0\jre\..\bin\javafxpackager" (in directory "D:\Documents and Settings\pterzie\My Documents\NetBeansProjects\JFX8M"): CreateProcess error=14001, This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1043) 
    at java.lang.Runtime.exec(Runtime.java:620) 
    at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58) 
    at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254) 
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319) 
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160) 
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610) 
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352) 
    ... 21 more 
Caused by: java.io.IOException: CreateProcess error=14001, This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem 
    at java.lang.ProcessImpl.create(Native Method) 
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386) 
    at java.lang.ProcessImpl.start(ProcessImpl.java:137) 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1024) 
    ... 28 more 

Czy istnieje przykład z Java 8 i Maven, który jest zaimplementowany i działa poprawnie?

P.S udało mi się zrobić to pracę po tym, jak usunąć wtyczkę. Redagowałem POM w ten sposób:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.dx57dc</groupId> 
    <artifactId>JFX8M</artifactId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 

    <name>JFX8M</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <mainClass></mainClass> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.8</version> 
       <executions> 
        <execution> 
         <id>unpack-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>unpack-dependencies</goal> 
         </goals> 
         <configuration> 
          <excludeScope>system</excludeScope> 
          <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds> 
          <outputDirectory>${project.build.directory}/classes</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>com.zenjava</groupId> 
       <artifactId>javafx-maven-plugin</artifactId> 
       <version>2.0</version> 
       <configuration> 
        <mainClass>com.dx57dc.jfx8m.MainApp</mainClass> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

Działa tylko dla JVM 8. Czy brakuje mi czegoś ważnego w pliku POM?

Odpowiedz

7

JavaFX 8 wykonywać pracę i będzie działać tylko z Java 8.

również sprawdzić aktualny plan JavaFX: http://www.oracle.com/technetwork/java/javafx/overview/roadmap-1446331.html

ja nie miałem żadnych problemów z coraz to działa.

  1. Pobierz i zainstaluj JDK8: https://jdk8.java.net/download.html 1.1. mieć pewność, że jest to jeden i oonly domyślnego JDK w systemie, jeśli nie wiesz, co robisz ...
  2. Pobierz Netbeans 7.4: https://netbeans.org/downloads
  3. w NetBeans (File -> New Project -> Project z Archetypu -> "wpisz pod javafx" -> "wybierz": javafx-basic-archetype) 3.1. nie zapomnij, aby ustawić nazwę organizacji
  4. pobrać &/Kopiuj Wklej JavaFX 8 klasa Przykład &/demo gdzieś, na przykład: http://carlfx.wordpress.com/2013/07/15/introduction-by-example-javafx-8-printing/ 4.1. Teraz ustaw źródła projektu na 1.8 i utf-8
  5. Oczyść i zbuduj i uruchom!
  6. Ciesz się!

W przypadku, gdy mają kłopoty w znalezieniu JavaFX-8-libs z Maven z konsoli lub z innego IDE, niż trzeba ustawić javafx-8-lib-path takiego:

  1. trzeba powiedzieć Maven gdzie javafx-lib jest dokładnie:

    <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.1</version> 
        <configuration> 
          <!-- this maven plugin does not functions with java 8 yet, passing java 7 is just fine. --> 
         <source>1.7</source> 
         <target>1.7</target> 
         <compilerArguments> 
          <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> 
         </compilerArguments> 
        </configuration> 
    </plugin> 
    

** Uwaga: nie trzeba używać tego konkretnego archetypu wspomniano powyżej, aby to działa ** Nic tak naprawdę nie jest złe, ale następnym razem wklej deltę treści, zamiast zamieszczać ją ponownie, bez delty wysiłek jest znacznie wyższy, ponieważ porównanie pliku musi zostać wykonane przez każdego, kto próbuje zrozumieć to ...