1

I created project in new Java SDK 11 based on this example:

EntryPoint.java

package com.example;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Label;

public class EntryPoint extends javafx.application.Application {

  public static void main (String[] args) {
    launch();
  }

  public void start(Stage stage) {
    Label label = new Label("Hello, JavaFX11!");
    Scene scene = new Scene(label, 640, 480);
    stage.setScene(scene);
    stage.show();
  }
}

pom.xml

<?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.example</groupId>
  <artifactId>Example</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
    </dependency>
  </dependencies>
</project>

No warnings from IntellIJ IDEA side. When I tried to compile, I got error (original is not in English, so it could be differ from original in English):

Error:(7, 20) java: Can not access to javafx.stage.Stage

Class C:\Users\XXXXX\.m2\repository\org\openjfx\javafx-graphics\11\javafx-graphics-11-win.
jar(javafx/stage/Stage.class) is invalid.

Class/File Version is 54.0; 52.0 is required.
Delete it, or set right directory.

Update

Tried to set JAVA_HOME system variable:

enter image description here

Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
  • 3
    *Make sure to set the JAVA_HOME environment variable to JDK 11.* – Naman Sep 26 '18 at 06:58
  • I’m not a Maven expert, but shouldn’t the required Java version appear somewhere, as it is a dependency after all? That would avoid such problems. To me “`Error:(7, 20) java: Can not access to javafx.stage.Stage`” does not look like a standard `javac` message, so if the build tool uses an embedded compiler, it needs an update for Java 11… – Holger Sep 26 '18 at 07:14
  • @nullpointer, I tried - zero effect. Is it everything correct on screenshot in question field? – Takeshi Tokugawa YD Sep 29 '18 at 01:55
  • Probably just make sure, your `mvnrc` includes correct java version and [maybe try using an explicit compiler plugin configuration](https://stackoverflow.com/questions/49398894/unable-to-compile-simple-java-10-project-with-maven/51586202#51586202) defined in the pom to ensure the java version used in compiling is 11 only. – Naman Sep 29 '18 at 03:06

1 Answers1

0

Just in case you can try add the maven dependency for Stage:

 <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>11</version>
  </dependency>

Idea showing that dependency comes from the specified dependency

Ruslan López
  • 4,433
  • 2
  • 26
  • 37