阿罗哈·盖伊(Aloha Guy),
我没有任何想法,我从胶粘剂开始就犯错了。
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
知道我有这个->
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'
}
并添加以下更改:
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'
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}"
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'
}
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做错了什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52684025/