Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
The workspace contains two folders by default, where:
src
: the folder to maintain sourceslib
: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the bin
folder by default.
If you want to customize the folder structure, open
.vscode/settings.json
and update the related settings there.
The JAVA PROJECTS
view allows you to manage your dependencies. More details can be found here.
The project requires installation of Some Dependencies for using JavaFx. These dependencies are crucial for running the program.
Download the latest version of JavaFx SDK. Extract the files to the desired location.
In your VS Code, at the Bottom Left corner, Click on JAVA PROJECTS
> Referenced Libraries
> Click on +
.
Now Add the all the JAR files located in javafx-sdk-version\lib
(Inside your Extracted Files) to the Referenced Libraries
.
Now, in the Tabs menu in VS Code, click on Run
> Add Configuration
. A launch.json
file will be created.
Add VM arguments to the launch.json
right under "projectName"
.
To do so Add "vmArgs": "--module-path "Path" --add-modules javafx.controls,javafx.fxml"
.
The path needs to be replaced with the Path of your lib
folder in your extracted files.