{"id":227727,"date":"2020-10-15T22:35:42","date_gmt":"2020-10-16T05:35:42","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/java\/?p=227727"},"modified":"2020-10-15T22:35:42","modified_gmt":"2020-10-16T05:35:42","slug":"java-on-visual-studio-code-update-september-2020","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-update-september-2020\/","title":{"rendered":"Java on Visual Studio Code Update \u2013 September 2020"},"content":{"rendered":"<p>Welcome to Java on Visual Studio Code Update. In September, we launched a new VS Code installer called <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-tutorial#_coding-pack-for-java\">Coding Pack for Java.<\/a> In this edition, we would like to focus on best practices of setting development environment. Regardless of whether you just want to explore or have already been using VS Code for projects or studies, we believe you all will benefit from these practices. Let\u2019s start.<\/p>\n<h3><strong>Your development environment <\/strong><\/h3>\n<p>When use VS Code, the first thing you have to know is what your development environment consists of. For Java development, your environment consists of <strong>VS Code<\/strong>, <strong>extensions<\/strong>, and <strong>JDK<\/strong>. \u00a0While VS Code provides you the best in class editing experience, more features are offered through extensions, for example, code completion, debugging, testing, building, project management, etc. VS Code has a broad ecosystem, where you can find all kinds of extensions to meet your specific needs. You can visit <a href=\"https:\/\/marketplace.visualstudio.com\/search?term=java&amp;target=VSCode&amp;category=All%20categories&amp;sortBy=Relevance\">VS Code Marketplace<\/a> to explore further.<\/p>\n<h3><strong>Coding Pack for Java<\/strong><\/h3>\n<p>To use VS Code for Java development, a very first thing is to set up your environment. <strong>Best practice #1:<\/strong>\u00a0using <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-tutorial#_setting-up-vs-code-for-java-development\">Coding Pack for Java<\/a>, if on Windows or MacOS, when set up for first time, upgrade, or even repair an existing environment. The pack will install VS Code, AdoptOpenJDK and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-pack\">Extension Pack<\/a>, a collection of essential extensions recommended by Microsoft, and also configure them automatically. When installation completes, you immediately have an integrated environment for your Java projects. The pack supports incremental updates by checking your environment firstly and only installs required pieces.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227729\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack-1024x823.png\" alt=\"Image Coding Pack\" width=\"640\" height=\"514\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack-1024x823.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack-300x241.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack-768x617.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/Coding-Pack.png 1197w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>The pack won\u2019t modify your existing project setting, so you don\u2019t have to worry using it will break your existing projects.<\/p>\n<h3><strong>Configuring JDK<\/strong><\/h3>\n<p>There are two JDK concepts involved in your development environment, JDK to run VS Code for Java (<strong>boot JDK<\/strong>) and JDK to build your project (<strong>project JDK<\/strong>). In VS Code, you can configure them separately. While boot JDK requires Java 11 or above version, project JDK supports any major version above Java 1.5. If Coding Pack is used, setting boot JDK has already been taken care by it.<\/p>\n<p><strong>Best practice #2:<\/strong> if encounter a JDK issue for running VS Code for Java, always checking VS Code setting: \u201c<strong>java.home<\/strong>\u201d to make sure it points to a JDK with Java 11 or above version. You can access the setting by clicking menu \u201c<strong>File-&gt;Preferences-&gt;Settings<\/strong>\u201d, searching \u201cjava.home\u201d on \u201cUser\u201d tab, and then opening the setting.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227733\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-1024x655.png\" alt=\"Image javahome\" width=\"640\" height=\"409\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-1024x655.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-300x192.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-768x492.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-1536x983.png 1536w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/javahome-2048x1311.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><strong>Best practice #3:<\/strong>\u00a0configuring your project JDK using VS Code setting: \u201c<strong>java.configuration.runtimes<\/strong>\u201d. You can access the setting by clicking menu \u201c<strong>File-&gt;Preferences-&gt;Settings<\/strong>\u201d, searching \u201cjava.configuration.runtimes\u201d on \u201cUser\u201d tab, and then opening the setting. You can set multiple JDK versions, and VS Code will pick the best version per your default or project\u2019s source level. For more details on how to set, please refer to <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-project#_configure-jdk\">Configure JDK<\/a>.<\/p>\n<h3><strong>Extension Pack \u00a0\u00a0\u00a0\u00a0<\/strong><\/h3>\n<p>If you are on Linux or just want to manually install VS Code, JDK and extensions instead of using Coding Pack for Java, <strong>best practice #4: <\/strong>installing Extension Pack instead of installing extensions individually. You can find Extension Pack from <a href=\"https:\/\/marketplace.visualstudio.com\/VSCode\">VS Code Marketplace<\/a> by searching \u201cJava extension pack\u201d, or when you first time open a \u201c.java\u201d file using VS Code, there will be a pop up message on bottom right corner of window for you to accept installing Extension Pack.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227732\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-1024x639.png\" alt=\"Image extension pack popup\" width=\"640\" height=\"399\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-1024x639.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-300x187.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-768x479.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-1536x958.png 1536w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-pack-popup-2048x1277.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3><strong>Extension Guide<\/strong><\/h3>\n<p>There are wide variety of extensions for VS Code. If you want to quickly extend your environment beyond Extension Pack, such as adding more framework support, application server support, or utility functions, <strong>best practice #5: <\/strong>leveraging Extension Guide. The guide provides you a wizard like experience for recommending and installing extension per your specific needs. You can launch the guide by clicking menu \u201c<strong>View-&gt;Command Palette\u2026<\/strong>\u201d and then type \u201cJava: Extension Guide\u201d in the palette.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227731\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-1024x655.png\" alt=\"Image extension guide\" width=\"640\" height=\"409\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-1024x655.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-300x192.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-768x491.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-1536x982.png 1536w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/extension-guide-2048x1309.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3><strong>More to know<\/strong><\/h3>\n<p>If you have followed our advices, a clean and properly set environment is already there at your disposal. If not yet, you can always come back to use them to upgrade or repair your environment. Here, we would like to share a couple of additional notes before you dive into your projects.<\/p>\n<ul>\n<li><strong>Project view<\/strong> helps you view your project and its dependencies and provides entry points for project management tasks. The view is on VS Code\u2019s side bar and named \u201cJAVA PROJECTS\u201d. For details, please refer <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-project#_project-view\">Project View.<\/a><\/li>\n<li>There are multiple ways to trigger <strong>run or debug<\/strong>:1) click menu \u201cRun\u201d and then select \u201cRun Without Debugging\u201d or \u201cStart Debugging\u201d, 2) hit \u201cCtrl+F5\u201d for run or \u201cF5\u201d for debugging, or 3) open a \u201c.java\u201d file and then click run or debug button on editor view. After kicking off, watch Debug Console for build status.\n<a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227734\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-1024x656.png\" alt=\"Image run\" width=\"640\" height=\"410\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-1024x656.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-300x192.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-768x492.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-1536x984.png 1536w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/run-2048x1311.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-227730\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-1024x655.png\" alt=\"Image debug console\" width=\"640\" height=\"409\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-1024x655.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-300x192.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-768x491.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-1536x983.png 1536w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/10\/debug-console-2048x1310.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/li>\n<li>VS Code maintains a rich set of <a href=\"https:\/\/code.visualstudio.com\/docs\"><strong>documents<\/strong><\/a><span style=\"font-size: 1rem;\">. For starting Java development, we found these documents are particularly useful: <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem;\" href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/userinterface\">User Interface<\/a><span style=\"font-size: 1rem;\">, <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem;\" href=\"https:\/\/code.visualstudio.com\/docs\/languages\/java\">Java in VS Code<\/a><span style=\"font-size: 1rem;\"> and \u00a0<\/span><a style=\"background-color: #f7f7f9; font-size: 1rem;\" href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-tutorial\">Getting Started with Java in VS Code<\/a><span style=\"font-size: 1rem;\">.<\/span><\/li>\n<\/ul>\n<h3>Try it out<\/h3>\n<p>Please don\u2019t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our product in future.<\/p>\n<ul>\n<li>Learn more about <a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/java\" target=\"_blank\" rel=\"noopener noreferrer\">Java on Visual Studio Code<\/a>.<\/li>\n<li>Explore our step by step <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-tutorial\" target=\"_blank\" rel=\"noopener noreferrer\">Java Tutorials on Visual Studio Code<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In September, we launched a new VS Code installer called Coding Pack for Java. In this edition, we would like to focus on best practices of setting development environment. Regardless of whether you just want to explore or have already been using VS Code for projects or studies, we believe you all will benefit from these practices.<\/p>\n","protected":false},"author":26010,"featured_media":227744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,8,15],"tags":[754,755,248,12],"class_list":["post-227727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-open-source","category-vscode","tag-coding-pack","tag-development-environment","tag-java","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>In September, we launched a new VS Code installer called Coding Pack for Java. In this edition, we would like to focus on best practices of setting development environment. Regardless of whether you just want to explore or have already been using VS Code for projects or studies, we believe you all will benefit from these practices.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/users\/26010"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/comments?post=227727"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227727\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/227744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=227727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=227727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=227727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}