redhat-developer / redhat-developer/vscode-java

Java Extension IDE Not recognizing Javafx imports. VSCODE App Compiles and Runs

未关闭
#3,883 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

This test app compiles and runs, but after 2 days of trying I cannot get rid of the wavy red lines to all references to javafx. The class file does not show any error. Also, Intellisense works and javafx is recognised until you hit enter and then the wavy line appears (see screen shot below).

I have included first line of "Problems" along with launch, tasks and settings json files.

For example:
[{
"resource": "/c:/Development-C/VSCode/Workspaces/Java/SimpleWindow/src/Main.java",
"owner": "generated_diagnostic_collection_namehttps://github.com/microsoft/vscode/issues/1",
"code": "errors(1): 1:8-1:14",
"severity": 8,
"message": "package javafx.application does not exist",
"startLineNumber": 1,
"startColumn": 8,
"endLineNumber": 1,
"endColumn": 14
},

Source Code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.layout.StackPane;

public class Main extends Application {
@OverRide
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");

Button btn = new Button("Close");
btn.setOnAction(e -> primaryStage.close());

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 200);

primaryStage.setScene(scene);
primaryStage.show();

}

public static void main(String[] args) {
launch(args);
}
}
Settings.json:
{
"java.home": "C:/Java/64bit/Oracle_JDK-23",
"java.debug.settings.hotCodeReplace": "manual",
"java.configuration.runtimes": [
{
"name": "JavaSE-23",
"path": "C:/Java/64bit/Oracle_JDK-23"
}
],
"java.project.referencedLibraries": [
"c:\Java\64bit\javafx-sdk-23.0.1\lib\javafx.base.jar",
"c:\Java\64bit\javafx-sdk-23.0.1\lib\javafx.controls.jar",
"c:\Java\64bit\javafx-sdk-23.0.1\lib\javafx.fxml.jar",
"c:\Java\64bit\javafx-sdk-23.0.1\lib\javafx.graphics.jar"
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch JavaFX",
"request": "launch",
"mainClass": "Main",
"vmArgs": "--module-path C:/Java/64bit/javafx-sdk-23.0.1/lib --add-modules javafx.controls,javafx.fxml"
}
],
"args": [
"--module-path", "C:/Java/64bit/javafx-sdk-23.0.1/lib",
"--add-modules", "javafx.controls,javafx.fxml"
]
}
and
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "javac",
"args": [
"--module-path",
"C:/Java/64bit/javafx-sdk-23.0.1/lib",
"--add-modules",
"javafx.controls,javafx.fxml",
"-d",
"bin",
"src/Main.java"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Screen Shot:
Image

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用提供的 Main.java、settings.json、launch.json 和 tasks.json,以及所示的 JavaFX SDK 路径,复现该诊断。检查为什么 Java 扩展会报告 JavaFX 导入缺失,尽管构建和启动配置都能成功执行。完成标准是 JavaFX 导入不再显示波浪线错误,同时示例仍能编译和运行。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, vscode
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。