gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:47:24 25 4
gpt4 key购买 nike

我不知道我一开始用 Gluon 做错了什么。

  1. 我有 IntelliJ IDEA 2018.2.4(社区版)
    版本 #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

  2. 安装 Gluon 插件版本:2.7.0

  3. 文件->新建->项目->gluon->使用 FXML 的桌面多 View 项目->java 11->完成

  4. 安装gradel Gradle 4.10.2 在上次安装 View 中将其用作本地选项

  5. 我使用java版本“11”2018-09-25

  6. 我下载了 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'
}

并添加以下更改:

  1. 根据 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'
  2. 为您的平台添加 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}"
  3. 添加与 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'
    }
  4. 根据指南,您需要添加模块路径并将所需的模块添加到编译器参数中:

    compileJava {
    doFirst {
    options.compilerArgs = [
    '--module-path', classpath.asPath,
    '--add-modules', 'javafx.controls,javafx.fxml'
    ]
    }
    }
  5. 运行参数也是如此。在这种情况下,可以使用 --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 项目。

Gluon Desktop

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com