The import javafx cannot be resolved

前端 未结 4 1039
傲寒
傲寒 2021-01-02 03:27

I installed Eclipse IDE today on my Ubuntu Linux and then installed JavaFX using \'Install New Software\' and when I created a javafx project, I got the following error in M

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 04:14

    Here's how to set it up on Ubuntu Linux with Maven:

    1) Install OpenJFX package, check where did it put the files.

          sudo apt install openjfx
          dpkg-query -L openjfx
    

    You might end up with version for JDK 11. In which case, either follow with installing a new OpenJDK, or set a version of OpenJFX for JDK 8.

    2) Put it to your Maven project as a system-scoped dependency.

    Note this is the lazy and not-so-nice way. Properly, you should install the jars like this:

    dpkg-query -L openjfx | grep -E '.jar$' | xargs -l -I{} \
      mvn install:install-file -Dfile="{}" -DgroupId=javafx \
        -DartifactId=$(echo $JAR | tr '.' '-') -Dversion=1.0 -Dpackaging=jar
    

    And then use it as a normal compile-scoped dependency.

    
        UTF-8
        1.8
        1.8
    
        /usr/share/openjfx/lib
    
    
    
    
        
        
            javafx
            javafx-base
            1.0
            system
            ${javafx.dir}/javafx.base.jar
        
        
            javafx
            javafx-controls
            1.0
            system
            ${javafx.dir}/javafx.controls.jar
        
        
            javafx
            javafx-fxml
            1.0
            system
            ${javafx.dir}/javafx.fxml.jar
        
        
            javafx
            javafx-graphics
            1.0
            system
            ${javafx.dir}/javafx.graphics.jar
        
        
            javafx
            javafx-media
            1.0
            system
            ${javafx.dir}/javafx.media.jar
        
        
            javafx
            javafx-swing
            1.0
            system
            ${javafx.dir}/javafx.swing.jar
        
        
            javafx
            javafx-web
            1.0
            system
            ${javafx.dir}/javafx.web.jar
        
    
    
    

提交回复
热议问题