0

When I run the getting started example: https://github.com/openjfx/samples/tree/master/HelloFX/Maven from the command line (OpenJDK 11, Maven 3.6.3) everything runs fine. When I open the same project in IntelliJ there is an error:

Error:(1, 26) java: cannot access javafx.application.Application bad class file: C:\Users\xxxxx\.m2\repository\org\openjfx\javafx-graphics\13\javafx-graphics-13-win.jar(javafx/application/Application.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

The Maven example in the IDE subfolder https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven/hellofx runs fine regardless of running from IntelliJ or the command line.

Any ideas why this is? For my own projects I do not want separate versions for the command line and IDE.

Robert Altena
  • 787
  • 2
  • 11
  • 26
  • 1
    Your IntelliJ project most likely is configured to run and build Java 8 (Class version 52). – maio290 Mar 14 '20 at 01:57
  • I would expect both examples to fail in the IDE if this was the correct answer. But I went back in and checked to make sure OpenJDK is the default JDK and is selected for both examples. – Robert Altena Mar 14 '20 at 02:34
  • 1
    The second example defines a compiler release (11) in the pom.xml which forces the maven compiler plugin to build for Java 11 (afaik) - the first one doesn't. If you try to copy this setting to the first example, I guess it might work there as well. – maio290 Mar 14 '20 at 02:40
  • I tried that before posting the question. Did not work. But it would explain why only one example works.. – Robert Altena Mar 14 '20 at 02:47
  • What are JDK and language level settings for the first and for the second project in IntelliJ IDEA? Please post the same screenshots as you see in https://stackoverflow.com/a/12900859/104891 . – CrazyCoder Mar 14 '20 at 03:06
  • Hello, thank you for having a look. I don't think this is in any way an IntelliJ settings problem. I have only one JDK installed: OpenJDK 11. I am happy to look up any specific settings you want to see. If anyone is able to clone the helloFX samples and compile/debug/run them right out of IntelliJ that would be good to know. It looks like JavaFX is so fragile that it requires a carefully tuned environment to build/run. – Robert Altena Mar 14 '20 at 23:01

0 Answers0