阿罗哈·盖伊(Aloha Guy),

我没有任何想法,我从胶粘剂开始就犯错了。

  • 我有intellj IDEA 2018.2.4(社区版)
    Build#IC-182.4505.22,建于2018年9月18日
    JRE:1.8.0_152-release-1248-b8 amd64
    JVM:JetBrains s.r.o的OpenJDK 64位服务器VM
    Windows 10 10.0
  • install Gluon插件版本:2.7.0
  • File-> new-> Projekt-> gluon-> Desktop Multi view Projekt with FXML-> java 11-> finish
  • install gradel Gradle 4.10.2在上次设置 View 中将其用作本地选项
  • 我使用Java版本“11” 2018-09-25
  • 我下载了javaFx11(openjfx-11_windows-x64_bin-sdk),并在结构中将其用作自由的

  • 知道我有这个->
    00:41:11: Executing task 'run'...
    
    
    > Task :compileJava FAILED
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:5: error: package javafx.scene.control does not exist
    import javafx.scene.control.Alert;
                               ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:7: error: package javafx.scene.image does not exist
    import javafx.scene.image.Image;
                             ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:8: error: package javafx.scene.image does not exist
    import javafx.scene.image.ImageView;
                             ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:7: error: package javafx.fxml does not exist
    import javafx.fxml.FXML;
                      ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:8: error: package javafx.scene.control does not exist
    import javafx.scene.control.Button;
                               ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:9: error: package javafx.scene.control does not exist
    import javafx.scene.control.Label;
                               ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:10: error: package javafx.scene.control does not exist
    import javafx.scene.control.TextInputDialog;
                               ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:27: error: cannot find symbol
        private Label label;
                ^
      symbol:   class Label
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:30: error: cannot find symbol
        private Button button;
                ^
      symbol:   class Button
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\SecondaryController.java:6: error: package javafx.fxml does not exist
    import javafx.fxml.FXML;
                      ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\SecondaryController.java:7: error: package javafx.scene.control does not exist
    import javafx.scene.control.Button;
                               ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\SecondaryController.java:20: error: cannot find symbol
        private Button button;
                ^
      symbol:   class Button
      location: class SecondaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\GluonApplication.java:4: error: package javafx.scene does not exist
    import javafx.scene.Scene;
                       ^
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\GluonApplication.java:7: error: cannot access Application
    public class GluonApplication extends ParticleApplication {
           ^
      class file for javafx.application.Application not found
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\GluonApplication.java:14: error: cannot find symbol
        public void postInit(Scene scene) {
                             ^
      symbol:   class Scene
      location: class GluonApplication
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:26: error: cannot find symbol
        @FXML
         ^
      symbol:   class FXML
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:29: error: cannot find symbol
        @FXML
         ^
      symbol:   class FXML
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:32: error: cannot find symbol
        @FXML
         ^
      symbol:   class FXML
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\SecondaryController.java:19: error: cannot find symbol
        @FXML
         ^
      symbol:   class FXML
      location: class SecondaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\SecondaryController.java:22: error: cannot find symbol
        @FXML
         ^
      symbol:   class FXML
      location: class SecondaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:24: error: cannot find symbol
            Alert alert = new Alert(AlertType.INFORMATION);
            ^
      symbol:   class Alert
      location: class MenuActions
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:24: error: cannot find symbol
            Alert alert = new Alert(AlertType.INFORMATION);
                              ^
      symbol:   class Alert
      location: class MenuActions
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:24: error: cannot find symbol
            Alert alert = new Alert(AlertType.INFORMATION);
                                    ^
      symbol:   variable AlertType
      location: class MenuActions
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:27: error: cannot find symbol
            alert.setGraphic(new ImageView(new Image(MenuActions.class.getResource("/icon.png").toExternalForm(), 48, 48, true, true)));
                                 ^
      symbol:   class ImageView
      location: class MenuActions
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\actions\MenuActions.java:27: error: cannot find symbol
            alert.setGraphic(new ImageView(new Image(MenuActions.class.getResource("/icon.png").toExternalForm(), 48, 48, true, true)));
                                               ^
      symbol:   class Image
      location: class MenuActions
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:51: error: cannot access StackPane
            app.getParticle().getToolBarActions().add(0, actionSignin);
                             ^
      class file for javafx.scene.layout.StackPane not found
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:55: error: cannot access ObservableList
            app.getParticle().getToolBarActions().remove(actionSignin);
                                               ^
      class file for javafx.collections.ObservableList not found
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:65: error: cannot find symbol
            TextInputDialog input = new TextInputDialog(stateManager.getProperty("UserName").orElse("").toString());
            ^
      symbol:   class TextInputDialog
      location: class PrimaryController
    E:\IntellijProjects\GluonDesktop-MultipleViewProjectwithFXML\src\main\java\com\gluonapplication\controllers\PrimaryController.java:65: error: cannot find symbol
            TextInputDialog input = new TextInputDialog(stateManager.getProperty("UserName").orElse("").toString());
                                        ^
      symbol:   class TextInputDialog
      location: class PrimaryController
    29 errors
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':compileJava'.
    > Compilation failed; see the compiler error output for details.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 0s
    1 actionable task: 1 executed
    Compilation failed; see the compiler error output for details.
    00:41:11: Task execution finished 'run'.
    

    我会错吗?

    最佳答案

    Gluon插件2.7.0不久前发布,主要用于使用Java 8创建Gluon Desktop或Gluon Mobile应用程序。

    如果现在使用的是Java 11,则在发布新版本的Gluon插件之前,您将不得不更新build.gradle文件。

    我建议您看看此guide中如何开始使用JavaFX 11,并检查此question有关将JavaFX 11添加到IntelliJ中的项目的信息。

    当您使用Gluon插件时,您将创建一个Gradle项目。为此,您无需下载整个JavaFX SDK,您可以通过Maven Central的依赖项将其包括在内。

    因此,编辑您的build.gradle文件,如下所示:

    apply plugin: 'java'
    apply plugin: 'application'
    
    repositories {
        jcenter()
        maven {
            url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
        }
    }
    
    mainClassName = 'com.gluonapplication.GluonDesktop'
    
    dependencies {
        compile 'com.gluonhq:particle:1.1.3'
    }
    

    并添加以下更改:
  • 根据Gradle指南,添加一种方法来查找哪个平台:
    apply plugin: 'java'
    apply plugin: 'application'
    
    def currentOS = org.gradle.internal.os.OperatingSystem.current()
    def platform
    if (currentOS.isWindows()) {
        platform = 'win'
    } else if (currentOS.isLinux()) {
        platform = 'linux'
    } else if (currentOS.isMacOsX()) {
        platform = 'mac'
    }
    
    repositories {
        jcenter()
        maven {
            url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
        }
    }
    
    mainClassName = 'com.gluonapplication.GluonDesktop'
    
  • 为您的平台添加JavaFX依赖项:
    dependencies {
        compile "org.openjfx:javafx-base:11:${platform}"
        compile "org.openjfx:javafx-graphics:11:${platform}"
        compile "org.openjfx:javafx-controls:11:${platform}"
        compile "org.openjfx:javafx-fxml:11:${platform}"
    
  • 添加与Java 9+兼容的ControlsFX依赖项(默认情况下使用的是Java 8+的8.40.14),并添加javax.annotation依赖项,它不属于Java 9+:
        compile 'com.gluonhq:particle:1.1.3'
        compile 'org.controlsfx:controlsfx:9.0.0'
        compile 'javax.annotation:javax.annotation-api:1.3.1'
    }
    
  • 根据指南,您需要添加module-path并将所需的模块添加到编译器参数中:
    compileJava {
        doFirst {
            options.compilerArgs = [
                    '--module-path', classpath.asPath,
                    '--add-modules', 'javafx.controls,javafx.fxml'
            ]
        }
    }
    
  • 和运行参数相同。在这种情况下,可以通过--add-exports来访问私有(private)API(由于ControlsFX的某些要求):
    run {
        doFirst {
            jvmArgs = [
                    '--module-path', classpath.asPath,
                    '--add-modules', 'javafx.controls,javafx.fxml',
                    '--add-exports', 'javafx.base/com.sun.javafx.runtime=ALL-UNNAMED',
                    '--add-exports', 'javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
                    '--add-exports', 'javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED',
    
            ]
        }
    }
    

  • 保存并同步更改,您应该能够运行Gluon Desktop项目。

    java - 我不知道我为Gluon Start做错了什么-LMLPHP

    关于java - 我不知道我为Gluon Start做错了什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52684025/

    10-11 06:54