To use Java within Visual Studio Code, you need to install a Java Development Kit (JDK) on your local environment. JDK is a software development environment used for developing Java applications. The Extension Pack for Java supports Java version 1.5 or above. Note: To configure JDKs for your projects, see Configure Runtime for Projects. To enable Java preview features, see How can I use VS Code with new Java versions. If you have never installed a JDK before and need to install one, we recommend you to choose from one of these sources:Ĭreate a folder for your Java program and open the folder with VS Code. Then in VS Code, create a new file and save it with the name Hello.java. When you open that file, the Java Language Server automatically starts loading, and you should see a language status item with a loading icon on the right side of the Status Bar showing the language status is busy. You can also choose to pin the status item in the status bar.Īfter it finishes loading, you can hover on the language status item and find the loading process has been finished successfully. Note: If you open a Java file in VS Code without opening its folder, the Java Language Server might not work properly. VS Code will also try to figure out the correct package for the new type and fill the new file from a template. You can also create a Java project using the Java: Create Java Project command. Bring up the Command Palette ( ⇧⌘P (Windows, Linux Ctrl+Shift+P)) and then type java to search for this command. After selecting the command, you will be prompted for the location and name of the project. You can also choose your build tool from this command. Visual Studio Code also supports more complex Java projects - see Project Management. You can use code snippets to scaffold your classes and methods. VS Code also provides IntelliSense for code completion, and various refactor methods. To learn more about editing Java, see Java Editing. To run and debug Java code, set a breakpoint, then either press F5 on your keyboard or use the Run > Start Debugging menu item. You can also use the Run|Debug CodeLens option in the editor. After the code compiles, you can see all your variables and threads in the Run and Debug view. The debugger also supports advanced features such as Hot Code Replace and conditional breakpoints.įor more information, see Java Debugging. The editor also has many more capabilities to assist with your Java workload.
0 Comments
Leave a Reply. |