{"id":227355,"date":"2020-02-19T11:14:22","date_gmt":"2020-02-19T19:14:22","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/java\/?p=227355"},"modified":"2020-02-19T11:14:22","modified_gmt":"2020-02-19T19:14:22","slug":"java-on-visual-studio-code-update-february-2020","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-update-february-2020\/","title":{"rendered":"Java on Visual Studio Code Update &#8211; February 2020"},"content":{"rendered":"<p>Welcome back to the second update of Java on Visual Studio Code in 2020.<\/p>\n<p>In this update, we will show you the new ways to manage your dependencies and configure your multiple JDK. You will learn the additional tools you can leverage for popular frameworks and runtimes. There&#8217;re also a few new code actions and improvements to checkout<span style=\"font-size: 1rem;\">. On to the update.<\/span><\/p>\n<h3>Managing Dependencies<\/h3>\n<p>Whether your use any build tool or not, Java Dependency Viewer now provides you an easy way to deal with your dependencies.<\/p>\n<h4>Maven<\/h4>\n<p>If you&#8217;re using Maven, now it&#8217;s very convenient for you to add dependency for your Maven project through Java dependency explorer by clicking the <span class=\"lang:default decode:true crayon-inline \">+<\/span>\u00a0 button as below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227364\" src=\"http:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/Kapture-2020-02-19-at-10.33.12.gif\" alt=\"Image Kapture 2020 02 19 at 10 33 12\" width=\"1226\" height=\"768\" \/><\/p>\n<h4>Other projects<\/h4>\n<p>If you&#8217;re not using any build tool like maven or gradle, and you want to reference binary jars in local file system, the experience is very similar to the maven experience above.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227361\" src=\"http:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/manage_dependencies.gif\" alt=\"Image manage dependencies\" width=\"1573\" height=\"1026\" \/><\/p>\n<p>Behind the scene, we&#8217;ve introduced a new setting <span class=\"lang:default decode:true crayon-inline\">java.project.referencedLibaries<\/span>. Below are the details about how to customize this setting.<\/p>\n<h5>Include libraries<\/h5>\n<p>The libraries to reference is described using a set of glob patterns:<\/p>\n<div class=\"highlight highlight-source-json\">\n<pre class=\"lang:default decode:true\">\"java.project.referencedLibraries\": [ \r\n    \"library\/**\/*.jar\", \r\n    \"\/home\/username\/lib\/foo.jar\" \r\n]<\/pre>\n<\/div>\n<p>In this way, all\u00a0<code>.jar<\/code>\u00a0files in workspace&#8217;s\u00a0<code>library<\/code>\u00a0folder, and\u00a0<code>foo.jar<\/code>\u00a0in the specified absolute path is added to the project&#8217;s external dependencies.<\/p>\n<p>The referenced libraries is then watched by VS Code, and the project will be refreshed once there&#8217;s change in these dependent files.<\/p>\n<p>By default, VS Code will reference all jar files in workspace&#8217;s\u00a0<code>lib<\/code>\u00a0directory using glob\u00a0<code>lib\/**\/*.jar<\/code>.<\/p>\n<h5>Exclude some libraries<\/h5>\n<p>If you want to exclude some libraries from the project, just expand\u00a0<code>java.project.referencedLibraries<\/code>\u00a0to full\u00a0<code>include-exclude-sources<\/code>\u00a0pattern and provide globs to\u00a0<code>exclude<\/code>\u00a0field:<\/p>\n<div class=\"highlight highlight-source-json\">\n<pre class=\"lang:default decode:true\">\"java.project.referencedLibraries\": { \r\n    \"include\": [ \r\n        \"library\/**\/*.jar\", \r\n        \"\/home\/username\/lib\/foo.jar\" \r\n    ], \r\n    \"exclude\": [ \r\n        \"library\/sources\/**\" \r\n    ] \r\n}<\/pre>\n<\/div>\n<p>In this way, any binary jar in\u00a0<code>library\/sources<\/code>\u00a0folder is ignored from the project&#8217;s external dependencies.<\/p>\n<h5>Attach source jars<\/h5>\n<p>By default, a referenced\u00a0<code>{binary}.jar<\/code>\u00a0will try to search\u00a0<code>{binary}-sources.jar<\/code>\u00a0under the same directory, and attach it as source if one match is found.<\/p>\n<p>If you want to manually specify a jar as source attachment, you can provide a key-value map in the\u00a0<code>sources<\/code>\u00a0field:<\/p>\n<div class=\"highlight highlight-source-json\">\n<pre class=\"lang:default decode:true\">\"java.project.referencedLibraries\": { \r\n    \"include\": [ \r\n        \"library\/**\/*.jar\", \r\n        \"\/home\/username\/lib\/foo.jar\" \r\n    ], \r\n    \"exclude\": [ \r\n        \"library\/sources\/**\" \r\n    ], \r\n    \"sources\": { \r\n        \"library\/bar.jar\": \"library\/sources\/bar-src.jar\" \r\n    } \r\n}<\/pre>\n<\/div>\n<p>In this way,\u00a0<code>bar-src.jar<\/code>\u00a0is attached to\u00a0<code>bar.jar<\/code>\u00a0as its source.<\/p>\n<p>Once external jar files are added, you can also see their file paths as description in Java Dependency Explorer.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227357\" src=\"http:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path.png\" alt=\"Image dependency jar path\" width=\"744\" height=\"159\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path.png 744w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path-300x64.png 300w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227358\" src=\"http:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_libraries.png\" alt=\"Image dependency jar path libraries\" width=\"664\" height=\"86\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_libraries.png 664w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_libraries-300x39.png 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227359\" src=\"http:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_maven.png\" alt=\"Image dependency jar path maven\" width=\"1129\" height=\"187\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_maven.png 1129w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_maven-300x50.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_maven-1024x170.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/02\/dependency_jar_path_maven-768x127.png 768w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/p>\n<h3><\/h3>\n<h3>Configure local JDK runtime<\/h3>\n<p>As Java evolves, lots of Java developers need to deal with multiple Java runtimes. Now we support a new preference mapping <code>java.configuration.runtimes<\/code> for Java execution environments. VS Code will detect the runtime required for your project and choose the appropriate one configured. See below as an example.<\/p>\n<pre><code>\"java.configuration.runtimes\": [\r\n        {\r\n            \"name\": \"JavaSE-1.8\",\r\n            \"path\": \"\/usr\/local\/jdk1.8.0_201\"\r\n        },\r\n        {\r\n            \"name\": \"JavaSE-11\",\r\n            \"path\": \"\/usr\/local\/jdk-11.0.3\",\r\n            \"sources\" : \"\/usr\/local\/jdk-11.0.3\/lib\/src.zip\",\r\n            \"javadoc\" : \"https:\/\/docs.oracle.com\/en\/java\/javase\/11\/docs\/api\",\r\n            \"default\":  true\r\n        },\r\n        {\r\n            \"name\": \"JavaSE-12\",\r\n            \"path\": \"\/usr\/local\/jdk-12.0.2\"\r\n        },\r\n        {\r\n            \"name\": \"JavaSE-13\",\r\n            \"path\": \"\/usr\/local\/jdk-13\"\r\n        }\r\n    ]\r\n<\/code><\/pre>\n<p>Runtime name must be one of: &#8220;J2SE-1.5&#8221;, &#8220;JavaSE-1.6&#8221;, &#8220;JavaSE-1.7&#8221;, &#8220;JavaSE-1.8&#8221;, &#8220;JavaSE-9&#8221;, &#8220;JavaSE-10&#8221;, &#8220;JavaSE-11&#8221;, &#8220;JavaSE-12&#8221;, &#8220;JavaSE-13&#8221;. We will update the list with each supported release of the JDK<\/p>\n<h3>Extensions for popular Java Frameworks and Runtimes<\/h3>\n<p>If you&#8217;re working with popular Java Frameworks such as Spring Boot and MicroProfile, Visual Studio Code has you covered as well. Below are some exciting new capabilities now available with those extensions<\/p>\n<ol>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items\/Pivotal.vscode-spring-boot\">Spring Boot Tools<\/a> now reports connection failures in live hover.<\/li>\n<li>Newly released <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=MicroProfile-Community.vscode-microprofile-pack\">MicroProfile Extension Pack<\/a> now includes <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=MicroProfile-Community.mp-starter-vscode-ext\">MicroProfile Starter<\/a> for you to quickly generate a MicroProfile Maven project along with development tools for runtimes such as <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=Open-Liberty.liberty-dev-vscode-ext\">Open Liberty<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=redhat.vscode-quarkus\">Quarkus<\/a> with lots of new features.<\/li>\n<li>If you&#8217;re working with any Red Hat server and runtime products such as Wildfly or JBoss, checkout <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=redhat.vscode-server-connector\">Server Connector<\/a> which allows you to start, stop and deploy to any of them.<\/li>\n<\/ol>\n<h3>More enhancements<\/h3>\n<p>The latest updates also brings a lot of other enhancements for Java experience in Visual Studio Code.<\/p>\n<ol>\n<li>New code actions\n<ul>\n<li>Remove the\u00a0<code>final<\/code>\u00a0modifier.<\/li>\n<li>Assign statement to new variable\/field.<\/li>\n<li>Remove redundant interfaces.<\/li>\n<li>Add missing case labels in switch statements.<\/li>\n<\/ul>\n<\/li>\n<li>Added <code>java.import.gradle.offline.enabled<\/code>\u00a0preference.<\/li>\n<li>Expose full completion proposals to 3rd party extensions. This will enable other extensions such as IntelliCode to provide you better IntelliSense experience without impacting the completion performance.<\/li>\n<li>Java Dependency Viewer\n<ul>\n<li>add <span class=\"lang:default decode:true crayon-inline\">Collapse All<\/span>\u00a0 support<\/li>\n<li>Support right click context menu for view nodes<\/li>\n<\/ul>\n<\/li>\n<li>Maven\n<ul>\n<li>Support to debug favorite commands.<\/li>\n<li>Add shortcut to view output when error occurs.<\/li>\n<li>Support to browse for local Maven binary if not found.<\/li>\n<\/ul>\n<\/li>\n<li>\u00a0Debugger\n<ul>\n<li>Provide context menu to continue\/pause all\/other threads.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 id=\"signup\">Sign up<\/h3>\n<p>If you&#8217;d like to follow the latest of Java on VS Code, please provide your email with us using the form below. We will send out updates and tips every couple weeks and invite you to test our unreleased feature and provide feedback early on.<\/p>\n<div data-form-block-id=\"a98bf458-e066-e911-a96e-000d3a340154\"><\/div>\n<p><script src=\"https:\/\/mktdplp102cdn.azureedge.net\/public\/1.35.1026.0\/static\/js\/form-loader.js\"><\/script><\/p>\n<div id=\"dgCPdzqBMykwIL6XsCcP3tC9zZGvAAN-t3ma0GiZE0QU\"><\/div>\n<p><script language=\"javascript\" type=\"text\/javascript\">(function (id, f, t, ws, ms_tr_il_08, ms_tr_il_w_01) { var tr = function (cb) { var count = 0; var callback = function () { if (count == 0) { count++; if (w) { w.w(id, t, cb); } } }; var ts = document.createElement('script'); ts.src = ws; ts.type = 'text\/javascript'; ts.onload = callback; ts.onreadystatechange = function () { if (this.readyState == 'complete' || this.readyState == 'loaded') { callback(); } }; var head = document.getElementsByTagName('head')[0]; head.appendChild(ts); }; if (typeof ms_tr_il_08 === 'function') { if (ms_tr_il_w_01 === null) { tr(function() { ms_tr_il_08(id, f, t); }); } else { ms_tr_il_w_01.w(id, t, function(websiteVisitedParams) { ms_tr_il_08(id, f, t, websiteVisitedParams); }); } } else { tr(); }})('gCPdzqBMykwIL6XsCcP3tC9zZGvAAN-t3ma0GiZE0QU', 'https:\/\/5a3318f6fcc34e41bf99d46845944055.svc.dynamics.com\/f', 'https:\/\/5a3318f6fcc34e41bf99d46845944055.svc.dynamics.com\/t', 'https:\/\/5a3318f6fcc34e41bf99d46845944055.svc.dynamics.com\/t\/w', typeof ms_tr_il_08 === \"undefined\" ? null : ms_tr_il_08, typeof ms_tr_il_w_01 === \"undefined\" ? null : ms_tr_il_w_01);<\/script><\/p>\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 this update for Java on VS Code, we will show you the new ways to manage your dependencies and configure your multiple JDK. We will also show you the additional tools you can use with popular frameworks and runtimes such as Spring Boot and Quarkus. There&#8217;re also a few new code actions and improvements to checkout. <\/p>\n","protected":false},"author":668,"featured_media":227370,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[567,248,568,12],"class_list":["post-227355","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-dependency-management","tag-java","tag-jdk","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>In this update for Java on VS Code, we will show you the new ways to manage your dependencies and configure your multiple JDK. We will also show you the additional tools you can use with popular frameworks and runtimes such as Spring Boot and Quarkus. There&#8217;re also a few new code actions and improvements to checkout. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227355","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/comments?post=227355"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227355\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/227370"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=227355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=227355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=227355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}