Joel
Joel

Reputation: 473

JavaFX project using Maven in NetBeans

In Netbeans 8.0 I develop JavaFX project using Maven. My java version is 1.7 and I have problems with upgrading to java 8. I tried to change <source> and <target> in pom-file to 1.8

  <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>

but I get error Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ...: Fatal error compiling: invalid target release: 1.8 -> [Help 1]

My JAVA_HOME environment variable set to java 1.8.

When I try to create new JavaFX project like File - New Project - Maven Category - JavaFX Application I still get project with JDK 1.7. How can I force to use JDK 1.8?

Upvotes: 2

Views: 1741

Answers (2)

Magician
Magician

Reputation: 73

you can add in maven tag properties this code

  <maven.compiler.source>1.8</maven.compiler.source>
     <maven.compiler.target>1.8</maven.compiler.target>

and check:

1-Tools -> Java Platform: add an entry for JDK 1.8.

2-the Project properties >> source window >> source/binaryFormat 1.8

Most of time the problem is (2):that netbeans create the JavaFx Maven project with the low jdk 1.7.

Upvotes: 2

Puce
Puce

Reputation: 38132

First you need to install JDK 1.8, of course.

Then either

  • in the installation directory set the default JDK location (netbeans_jdkhome property in etc/netbeans.conf )

or

  • in Tools -> Java Platform: add an entry for JDK 1.8
  • in the Project properties set the Java Platform to JDK 1.8

I also recommend to use NetBeans 8.x when working with JDK 1.8

Upvotes: 3

Related Questions