Try debugging a Java program with VS Code

Visual Studio Code (hereinafter VS Code) continues to evolve like a rage once a month, but recently it seems that Java debugging can be executed, so try it. Try.

Things necessary

procedure

Launch VS Code

Install the extension Java Extension Pack

--Open Extension View (Ctrl + Shift + X or ⇧⌘X) --Enter java pack in the input field to search for Java Extention Pack. --Click Install --Click Reload after installation --In addition, Debugger for Java and Language support for Java for Visual Studio Code are also installed.

image.png

Open Java project

--Open the Java project you want to run in VS Code. --At this time, if you get angry that "Java runtime could not be located", set the JDK. If you don't get angry, go ahead.

JDK settings

--Open the user settings screen (Ctrl +, or ⌘,) --Enter javahome in the input field to find the setting item java.home. --Click the pen icon displayed on the left side of java.home and click" Copy to Settings ". The editable settings will be copied on the right side, so enter the path of the JDK of your environment. And save. --Restart VS Code or close and reopen the project.

image.png

Run

--Open debug view (Ctrl + Shift + D or ⇧⌘D). --Click the gear icon (open launch.json) at the top of the view and select "Java". --A .vscode / launch.json file will be created and will automatically create settings for each executable class in your project. --If you want to switch the class you want to execute, select it in the list box at the top of the debug view.

image.png

--Press F5 to run debugging.

image.png

--Breakpoints can be found by clicking on the left side of the line number. --If you execute it again with F5, the process will stop at the specified location and the variable value will be displayed on the left side.

image.png

――SpringBoot works fine, and if it's just a little research or operation check, it seems that this is fine instead of IDEA.

What I was interested in using

--When the configuration files such as xml are placed under the resources folder, the build is not performed even if those files are updated. It will be reflected when the project is reloaded. --For the time being, manual support is provided by updating some java file at the same time when the configuration file is modified.

Recommended Posts

Try debugging a Java program with VS Code
Build a Java development environment with VS Code
[Environment construction] Build a Java development environment with VS Code!
Java build with mac vs code
A memo to start Java programming with VS Code (2020-04 version)
Prepare Java development environment with VS Code
Try using Spring Boot with VS Code
[Note] A story about changing Java build tools with VS Code
Lombok with VS Code
Using Gradle with VS Code, build Java → run
Try remote debugging of Java with Remote Containers in Visual Studio Code Insiders
Build Java development environment with VS Code on Mac
Export pdf with a single program (Java / Perl / VBA)
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
Build Java program development environment with Visual Studio Code
Try building Java into a native module with GraalVM
Docker management with VS Code
Format Ruby with VS Code
Hello World with VS Code!
Create a VS Code Plugin.
Create a Java (Gradle) project with VS Code and develop it on a Docker container
Create a Java (Maven) project with VS Code and develop it on a Docker container
Java program to resize a photo into a square with margins
[Beginner] Try to make a simple RPG game with Java ①
Java web application development environment construction with VS Code (struts2)
Try developing a containerized Java web application with Eclipse + Codewind
Build a Java project with Gradle
Code Java from Emacs with Eclim
Java Spring environment in vs Code
Java 15 implementation and VS Code preferences
Spring Boot programming with VS Code
Execute packaged Java code with commands
Try bidirectional communication with gRPC Java
Getting Started with Docker with VS Code
Java development environment (Mac, VS Code)
Try to speed up Java console program startup with GraalVM native-image
Settings to delete unused Java imports when saving with VS Code
Building a haskell environment with Docker + VS Code on Windows 10 Home
How to open a script file from Ubuntu with VS code
A record of setting up a Java development environment with Visual Studio Code
Link Java and C ++ code with SWIG
A memorandum when IME cannot be turned on with VS Code (Ubuntu 20.04)
Let's try WebSocket with Java and javascript!
[Introduction to Java] How to write a Java program
Try running a Kubernetes Job from Java
Hello World on Mac VS Code Java
Try making a calculator app in Java
[JaCoCo (Java Code Coverage)] Use with NetBeans
Split a string with ". (Dot)" in Java
Try managing Java libraries with AWS CodeArtifact
Execute Java code from cpp with cocos2dx
Try using the Wii remote with Java
Introduction to Java development environment & Spring Boot application created with VS Code
Connect with VS Code from a Windows client to Docker on another server
From creating a Spring Boot project to running an application with VS Code
I made a primality test program in Java
Create a CSR with extended information in Java
Create a simple bulletin board with Java + MySQL
Let's create a timed process with Java Timer! !!
Run a Spring Boot project in VS Code