Issue
I have had this launch.json file look this way for most of the time I have had my project. I am not entirely sure what the file's purpose is or what the specific lines do. I had a compile build fail last night saying that it couldn't find my main file "Planner" even though it was working fine and it broke after pushing my updates to GitHub via the GitHub Desktop program. Anyway, this got me wondering if I really need all of these very similar blocks in my launch.json file, or if I really should only have one. My thought is the others are old variations of where files were? I have worked on this project on several machines and pushed/pulled from GitHub a lot.
Edit:
From the comments I should provide more information. Apologies, the initial post was made at work when I only had GitHub code to reference, and not my IDE. I have a program I have been building in VSCode, who's main class is called "Planner", file Planner.java. I have been working on this project for a little over six months and have been really teaching myself javaFX, as my AS degree in Computer Science really only covered Java concepts so they kept to the standard Java library. With that, I followed some tutorials and got JavaFX working in VSCode. Last night I made some updates to my program that ran fine. I then pushed it to GitHub, shut my PC down, and was going to be done. I turned back on the PC and went back in to make one last change I had thought of and get an error: "Build failed, do you want to continue? [Source: Debugger for Java (Extension)]"
I guess I am asking two things, tips on understanding the launch.json file,(do I need to write, what seems like the same thing, 5 times to have the code compile and run?) and ideas for what could be causing the error described. Apologies, this is my first time posting here, I use the site a lot by reading others issues and fixing mine, but no experience posting, please let me know if I am asking too broad a question, or not being clear. Details below:
In the Terminal:
Error: Could not find or load main class Planner
Caused by: java.lang.ClassNotFoundException: Planner
In the "Problems:" section of VSCode:
Project 'SimplePlanner1_52208f3' has no explicit encoding set
[{
"resource": "/C:/Users/travi/AppData/Roaming/Code/User/workspaceStorage/fd9ee5418b12f7a629c4aeb2c52147e1/redhat.java/jdt_ws/SimplePlanner1_52208f3/",
"owner": "_generated_diagnostic_collection_name_#2",
"code": "0",
"severity": 4,
"message": "Project 'SimplePlanner1_52208f3' has no explicit encoding set",
"source": "Java",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1 }]
launch.json file:
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Planner",
"request": "launch",
"vmArgs": "--module-path \"C:/Users/travi/Documents/Software Development/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml",
"mainClass": "Planner",
"projectName": "SimplePlanner1_52208f3"
},
{
"type": "java",
"name": "Launch Planner",
"request": "launch",
"vmArgs": "--module-path \"C:/Users/travi/Documents/Software Development/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml",
"mainClass": "Planner",
"projectName": "SimplePlanner1_cd0129b4"
},
{
"type": "java",
"name": "Launch Planner",
"request": "launch",
"vmArgs": "--module-path \"C:/Users/travi/Documents/Software Development/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml",
"mainClass": "Planner",
"projectName": "SimplePlanner_69fc3f9d"
},
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"vmArgs": "--module-path \"C:/Users/travi/Documents/Software Development/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch Planner",
"request": "launch",
"mainClass": "Planner",
"projectName": "Engr290-12-5-21-planner-main_478f1ccb",
"vmArgs": "--module-path \"C:/Users/travi/Documents/Software Development/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml"
}
]
}
Another Edit:
I went in and tried to delete out the block that has the line referencing SimplePlanner1_52208f3, and run the code. When running the code and that isn't there, the compiler automatically adds back in the following block of code to my launch.json file. So maybe I am barking up the wrong tree and its a deeper issue?
{
"type": "java",
"name": "Launch Planner",
"request": "launch",
"mainClass": "Planner",
"projectName": "SimplePlanner1_52208f3"
},
Solution
The answer to how to get the code running is found here:
VScode complains that Java project has no explicit encoding set
Thank you,
Answered By - RavisDee
Answer Checked By - Mildred Charles (JavaFixing Admin)