我正在使用 VScode 和场景生成器开发 javafx 项目,我使用 fontawesome-8.2.jar 添加图标。当我尝试运行代码时,它给了我一个错误,如果我删除 fontawesome 图标,它就可以正常工作。 我认为问题是我需要在配置中添加 fontawesome 但我不知道如何。
这是我的配置:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "CafeShopManagmentSystem",
"request": "launch",
"mainClass": "CafeShopManagmentSystem",
"projectName": "CafeShopManagementSystem_4876995e",
"vmArgs": "--module-path \"C:/java/lib\" --add-modules javafx.controls,javafx.fxml"
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
}
]
}
我尝试像这样在配置中添加 fontawsome,但它不起作用:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "CafeShopManagmentSystem",
"request": "launch",
"mainClass": "CafeShopManagmentSystem",
"projectName": "CafeShopManagementSystem_4876995e",
"vmArgs": "--module-path \"C:/java/lib\" --add-modules javafx.controls,javafx.fxml,**fontawesome-8.2"**
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
}
]
}
仅供参考,fontawesome 库与 javafx 库位于同一文件夹中。
尝试以下配置:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "CafeShopManagmentSystem",
"request": "launch",
"mainClass": "CafeShopManagmentSystem",
"projectName": "CafeShopManagementSystem_4876995e",
"vmArgs": "--module-path \"C:/java/lib;C:/path/to/fontawesome-8.2.jar\" --add-modules javafx.controls,javafx.fxml",
"classPaths": ["C:/path/to/fontawesome-8.2.jar"]
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
}
]
}
确保将
C:/path/to/fontawesome-8.2.jar
替换为 FontAwesome JAR 文件的实际路径。另外,请确保 FontAwesome JAR 文件位于正确的位置。