On Mac, with VsCode (Visual Studio Code) instead of Eclipse This article is for those who want to develop Java.
For those who want to develop in Eclipse instead of VsCode Please refer to "Java Development Environment (Mac, Eclipse)" in Qiita.
If you haven't installed Java yet "Install Java (Mac, Homebrew, multiple version control)" Please complete the installation first by referring to.
My environment that I confirmed the operation is as follows.
OS: macOS Catalina(Version 10.15.4)
Java: 11.0.2
If you have already installed it, please skip it.
[Download page] on the official website (https://code.visualstudio.com/download) Select your Mac and download it.
I think that a file called "VSCode-darwin-stable.zip" will be downloaded. Double click.
↓
A file called "Visual Studio Code.app" will be created in the same folder.
Copy this file to your application folder.
↓
Right-click "Visual Studio Code.app" in the application folder and click Press "Open" to start.
↓
The Java Overview and preview page are displayed. When "Enable Semantic highlighting for Java by default?" Is displayed at the bottom right of the window, press "Enable".
Enter the following code.
class Main {
public static void main(String[] args) {
String msg = "";
msg += "Hello ";
msg += "World!";
System.out.println(msg);
}
}
If you remove the semicolon (even if you haven't saved it), a red squiggly line will tell you the error.
Click the error display icon at the bottom left to see the details of the error.
class Main When public static void main(String[] args) { A button "Run | Debug" is displayed between, so press it to execute it. "Hello World!" Is displayed in the terminal.
When you see the link "Create a launch.json file" in the menu on the left Press it. Then, the menu on the left changes to a screen that looks like debug execution.
Click the left edge of the 5th line of Main.java to set a "breakpoint".
Then press the run button at the top of the left menu. Then the processing stops at the 5th line.
When you press the "Step over" button among the icons displayed at the top Go line by line
How was building a Java development environment using Visual Studio Code on Mac?
Buttons such as Step Over and Step In when debugging I think the watch expression, call stack, breakpoints, etc. are the same as those used in the IDE (Integrated Environment). I think that a lot of information about this area will come out if you google with "debug execution" etc., so I will omit it here.
end.
Recommended Posts