Here is a first article and an official document
For Java developers who use Visual Studio Code, the Language support to Java (TM) by Red Hat extension provides very good language features, such as IntelliSense and project support. However, we also hear some user feedback that requires debugging Java programs. Today, we are excited to announce that we have partnered with Red Hat to develop a lightweight extension that allows developers to debug Java applications: Java Debugger for Visual Studio Code, which is based on Java debug Server.
Note: Java Debugger for Visual Studio code and Java Debug Server will be open source shortly after the initial release.
To enable Java developers to start using VS Code as soon as possible, we also created a Java extension package that contains the Language support for Java (TM) by Red Hat and Java Debugger for Visual Stu Dio Code These two extensions so that you do not need to go through the search to install these extensions separately. This is a modern Java workflow that is just beginning to be created and we will add more features and extensions to the Java extension package in the future.
Begin
Start with the following steps:
Open the Extended view (ctrl+shift+x) in Visual Studio Code.
Enter "Java" to filter the list of extensions.
Locate and install the Java Extension Pack (Java expansion pack), or you can find and install the Java Debugger for Visual separately if you have installed Language support for Java (TM) by Red Hat Studio Code extension.
You can also install the Java extension package directly from this article:
Install the Java expansion pack (with Vscode installed, click on the link above to call Vscode for installation)
Restart Vscode, open the code that contains the Java project, and then follow the steps below:
Prepare the project. Opens a. java file, and the Java extension is activated. Maven, Gradle, and Eclipse projects are supported. This extension will automatically build the project without the need to trigger the build manually.
Start Debugging. Switch to debug view (ctrl+shift+d), open Launch.json and add Java Debug Configuration.
Fill in the MainClass with the class you want to start, or fill in the HostName with the host name you want to attach and fill in the port.
Set breakpoints and press F5 to start debugging.
Supported Features
In this release, we support the following features:
Start/Attach-you can start a Java project in VS Code, or you can attach to a JVM process that runs in debug mode on either the local or remote side.
Breakpoints-supports expression conditions or hit conditional breakpoints, which can be easily set in the built-in breakpoint settings container. So you can insert breakpoints directly in the source view, which is handy without having to pop up the container. It is also supported by an abnormal interrupt.
Control flow-Includes pausing, continuing F5, Stepping F0, stepping F11, stepping out (jumping out) shift+f11.
Data review-When the program stops on a breakpoint, the debugger can access the variable names and values in the current memory. Supports viewing/monitoring/setting variable values.
Diagnostics-The Call stack panel displays the program's call stack, where you can jump freely in the captured call path. Multithreaded debugging is also supported through and stacks.
Debug console-You can see standard output and error output information from the Debug console.
Official documents:
The Java support in VS Code are provided through extensions and optimized for lightweight Java projects with a simple, mode RN Workflow. Popular extensions in the Marketplace provide project support, code completion, linting, debugging, code formatting, Snipp ETS, and more.
Download vs Code-if you haven ' t downloaded vs Code yet, quickly install for your platform (Windows, Mac, Linux).
Install Java Extensions
VS Code is a fast editor and ships with only the basic features. ADD Java language Support to VS Code by installing the popular Java extensions.
- In Visual Studio Code, go to the Extensions view (ctrl+shift+x).
- Filter the extensions list by typing "java".
To help set up Java on VS Code, there is a Java Extension Pack which contains, popular extensions:
- Language support for Java (TM) by Red Hat
- Java Debugger for Visual Studio Code
Install the Java Extension Pack
This document describes the features included in the Java Extension Pack.
Java Project Support
Maven, Eclipse and Gradle Java project is supported through Language support for Java (TM) by Red Hat, by utilizing M2ECLI PSE which provides Maven support and buildship which provides Gradle support through the Eclipse JDT Language Server.
Please note that gradle-based Android projects is not supported.
Editing and Navigating Code
Linting
A linter is a tool which provides warnings for suspicious looking code. Language support for Java (TM) by the Red Hat provides this feature to the report parsing and compilation errors as you type, so yo u can fix them inside VS Code.
Intellisense
VS Code also supports code completion and Intellisense for Java through Language support for Java (TM) by Red Hat. Intellisense is a general term for a number of features, including intelligent code completion (In-context method and Vari Able suggestions) across all your files and for built-in and thirty-party modules.
Search for Symbols
You can search for symbols in the current file or workspace to navigate your code more quickly.
To search for a symbol in the current file, Use quick open (ctrl+p" then enter the ' @ ' command and then enter the name of the ' the ' symbol of your ' re looking for. A list of potential matches would appear and is filtered as you type. Choose from the list of matches to navigate to their location.
To search for a symbol in the current workspace, start by pressing ctrl+t and then enter the name of the symbol. A list of potential matches would appear as before. If you choose a match this is found in a file that's not already open, the file would be opened before navigating to the M Atch ' s location. Alternatively, you can also use Quick Open (ctrl+p) and then enter the ' # ' command to search for the current workspace. Ctrl+t is just the shortcut for the ' # ' commands, respectively, so everything works the same.
Peek Definition
You can take a quick look at how a symbol is defined by using the Peek Definition feature. This feature displays a few lines of code near the definition inside a peek window so you can take a look without Navigati Ng away from your.
To peek at a symbol's definition, place your cursor on the symbol anywhere it's used in your source code and then press alt+f12. Alternatively, you can choose Peek Definition from the context menu (right-click, then choose Peek Definition).
Go to Definition
You can also quickly navigate to where a symbol are defined by using the Go to Definition feature.
To go to a symbol's definition, place your cursor on the symbol anywhere it used in your code and then press F12. Alternatively, you can choose Go to Definition from the context menu (right-click, then Choosego to definition). When there's only one definition of the symbol, you'll navigate directly to their location, otherwise the competing Definiti ONS is displayed in a peek window as described in the previous sections and you had to choose the definition so you wan T to go.
Other code editing features include:
- Code formatting
- Code Snippets
- Code outline
- Code Lens (References)
- Javadoc hovers
- Rename
- Highlights
Debugging
Java Debugger for Visual Studio Code was a lightweight Java Debugger based on Java Debug Server. It works with Language support for Java by Red Hat to allow users debugging Java code using Visual Studio code (VS code).
The Java Debugger supports following features:
- Launch/attach-you can either Launch the Java project within VS Code or Attach to any running JVM process in debug mode, Locally or remotely.
- Breakpoints-conditional breakpoints by hits Count is supported and can easily be set using the inline breakpoint settings Window. This allows-conveniently add conditional breakpoints to your code, directly in the source viewer, without requiring A modal window. Break on exceptions is also supported.
- Control flow-including Pause, Continue
F5
, step over F10
, step to F11
, step outShift+F11
- Data inspection-when you ' re stopped at a breakpoint, the debugger have access to the variable names and values that is C urrently stored in memory. Inspect/watch/set Variables is supported.
- Diagnostics-the Call stack panel shows the "Call stack of your" and allows to navigate through the call path O F each captured allocation. Multi-threaded debugging is supported by parallel stacks.
- Debug Console-the Debug Console lets you see information from both stdout and stderr.
You can launch the debugger following steps below:
- Switch to the Debug view (ctrl+shift+d).
- Open to
launch.json
Add a debug configuration for Java
- Fill in the
mainClass
to Launch
setting or and for hostName
port
Attach
.
- Click Start button or press to
F5
Start debugging.
Next Steps
Read on to the find out about:
- Basic Editing-learn about the powerful VS Code editor.
- Code Navigation-move quickly through your source code.
- Tasks-use tasks to build your project and more
- Debugging-find out how to use the debugger with your project
Reprinted from: Http://blog.csdn.net/bat67
JAVA Basics-development environment Vscode build