{"id":224941,"date":"2019-05-01T10:00:45","date_gmt":"2019-05-01T17:00:45","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=224941"},"modified":"2019-11-14T15:06:25","modified_gmt":"2019-11-14T23:06:25","slug":"java-on-visual-studio-code-april-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-april-update\/","title":{"rendered":"Java on Visual Studio Code April Update"},"content":{"rendered":"<p>Welcome to April update! Java 12 is now officially supported with Visual Studio Code. We&#8217;d also like to show you some new and helpful code actions now available, along with new features from Debugger, Maven and CheckStyle.<\/p>\n<p>Try these new features by installing <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-pack\" target=\"_blank\" rel=\"noopener noreferrer\">Java Extension Pack<\/a> with Visual Studio Code. See below for more details!<\/p>\n<h3>Java 12 Support<\/h3>\n<p>Java is now updating with a faster pace and we&#8217;re following closely. Thanks to the upstream update from JDT, you can build your project with Java 12 features now with VS Code as well. To use the experimental language features such as the new <code>switch<\/code> statement, add the following settings to <code>pom.xml<\/code>:<\/p>\n<pre class=\"lang:default decode:true \">&lt;build&gt;\r\n    &lt;plugins&gt;\r\n        &lt;plugin&gt;\r\n            &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\r\n            &lt;version&gt;3.8.0&lt;\/version&gt;\r\n            &lt;configuration&gt;\r\n                &lt;source&gt;12&lt;\/source&gt;\r\n                &lt;compilerArgs&gt;--enable-preview&lt;\/compilerArgs&gt;\r\n            &lt;\/configuration&gt;\r\n        &lt;\/plugin&gt;\r\n    &lt;\/plugins&gt;\r\n&lt;\/build&gt;<\/pre>\n<h3>Easier Getting Started<\/h3>\n<p>Although Java has been there for a long time, it still attracts new developers, and we&#8217;d like to make sure it&#8217;s easy enough for anyone to start programming Java with VS Code. One of the improvement we made recently is to provide you more detailed information to fix your environment setting.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225017\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/JDKDiagnostic.png\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<p>What if you don&#8217;t yet have JDK installed? No problem. When the Java extension pack is loaded, we will automatically detect whether a JDK is present. If not, we will provide you links to download reliable JDK at your choice.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225017\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/JDKInstall1.png\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<p>Better yet, we&#8217;re also working on a customized VS Code distribution which will help get you ready with everything needed for Java development with a single installer. To learn more, please\u00a0<a href=\"#signup\">sign up<\/a> at the end of this post to receive latest news and updates for Java on VS Code.<\/p>\n<h3>Performance Improvements<\/h3>\n<p>We&#8217;ve been benchmarking and profiling the performance of VS Code for Java, on all platforms and major scenarios including loading and editing. There were several enhancement to improve performance in recent releases.<\/p>\n<ul>\n<li>Improved editing performance when dealing with large amount of source file opened in the editor<\/li>\n<li>Optimize start up and load time with better server initilization and lazy downloading Java source<\/li>\n<\/ul>\n<p>As we try our best improving performance, it would still take some time when importing a big Java project to Visual Studio Code. In this case, it would be helpful to show more progress details and let you know what&#8217;s actually happening behind the scene. Instead of just showing the percentage of progress, we now added detailed step information into the status, such as inspecting location, configuring project, updating Maven dependencies, refreshing workspace and build workspace to let you know the wait is meaningful.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225074\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/start-progress.jpg\" alt=\"\" width=\"1947\" height=\"96\" \/><\/p>\n<h3>More Code Actions<\/h3>\n<p>Code actions are key to your productivity, so we keep bringing more of them to Visual Studio Code.<\/p>\n<h5>Resolve ambiguous imports<\/h5>\n<p>To deal with ambiguous imports, you now have a dropdown list to pick the right one. The code line with the unresolved type is also presented to you to help you decide.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225039\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.organize.imports.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Generate hashCode() and equals()<\/h5>\n<p>Now\u00a0<code>hashCode()<\/code>\u00a0&amp;\u00a0<code>equals()<\/code>\u00a0can be generated with default implementations. All the non-static member variables are listed, and you can customize the generated code using the check list.<\/p>\n<p>There are two options for you to customize the generated code:<\/p>\n<ul>\n<li>If you use Java 7+, you can set\u00a0<code>java.codeGeneration.hashCodeEquals.useJava7Objects<\/code>\u00a0to\u00a0<code>true<\/code>\u00a0to generate shorter code which calls\u00a0<code>Objects.hash<\/code>\u00a0and\u00a0<code>Objects.equals<\/code>.<\/li>\n<li>You can also set\u00a0<code>java.codeGeneration.hashCodeEquals.useInstanceof<\/code>\u00a0to check the object type instead of calling\u00a0<code>Object.getClass()<\/code>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225041\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.hashcode.equals.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Generate toString()<\/h5>\n<p>Picking which fields to be included in the <code>toString()<\/code> method and configure its template are all supported with the Generate <code>toString()<\/code> code action.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225042\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.generate.tostring.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Extract to local variable<\/h5>\n<p>To create a new variable (correctly typed) from the return value of an expression, the new quick fix\u00a0<code>extract to local variable<\/code>\u00a0provides a<span style=\"font-size: 1rem;\">\u00a0quick fix bulb which appears when the cursor stops at the bracket\u00a0<\/span><code>()<\/code><span style=\"font-size: 1rem;\">. The keyboard shortcut is\u00a0<\/span><code>ctrl + .<\/code><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225045\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/extract_variable.gif\" alt=\"\" width=\"639\" height=\"175\" \/><\/p>\n<h5>Override\/Implement methods<\/h5>\n<p>With this new source action, all the cadidates are presented to you with a checklist. Then you can decide what to override or implement.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225040\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.implement.methods.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Add static import<\/h5>\n<p>You can now convert static functions calls to static imports.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225043\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.convert.static.import.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h3>Folding Range<\/h3>\n<p>Now you can expand or collapse sections of code to make your Java file easy to read. We&#8217;ve enabled a couple popular ways for you to specify which code elements should be considered as a region to fold.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225044\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.folding.range_.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h3><\/h3>\n<h3>Debugger Updates<\/h3>\n<p>Debugger is one of the most used extension in the Java extension family, and we&#8217;re excited to show you the improvements below<\/p>\n<h5>Display Logical Structure of Collections<\/h5>\n<p>The debugger is now showing the logical structure of lists and maps, instead of the physical layout of the collections.\u00a0If you prefer the physical layout view, you can go back by setting\u00a0<code>java.debug.settings.showLogicalStructure<\/code>\u00a0to\u00a0<code>false<\/code>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225046\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.debug_.logical.structure.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Hightlight Exceptions in Editor<\/h5>\n<p>Exceptions are now highlighted with extra info in the editor window. Before that, you need to hover on the exception to see details. Now the most important info is presented to you right at where it occurs.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225047\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/java.debug_.exception.view_.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Go to Definition by Clicking Stack Trace in Debug Console<\/h5>\n<p>When there an exception, you can now click on the stack trace to see the definition of the function calls.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225048\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/debug.gtd_.stack_.trace_.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<p>Other notable featutes include<\/p>\n<ul>\n<li>Auto-completion in debug console for types without source code<\/li>\n<li>Auto shorten the command line when file name or extension is too long.<\/li>\n<\/ul>\n<p><a name=\"#maven-update\"><\/a><\/p>\n<h3>Maven Updates<\/h3>\n<p>And a couple new features for Maven as well.<\/p>\n<h5>Debug Maven Plug-in Goal<\/h5>\n<p>Now you can easily configure your breakpoint and start debug any Maven goals with just a couple clicks.<\/p>\n<h3><img decoding=\"async\" class=\"alignnone size-full wp-image-225050\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/debug-maven-plugin-goal.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/h3>\n<h5>Customize maven commands<\/h5>\n<p>Now you are able to specify your favorite commands in settings for future execution.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225051\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/favorite-commands.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<h5>Show Dependency Tree<\/h5>\n<p>We also support showing dependencies in a tree view which allows you to inspect all dependencies in your project at a single place and check for potential issues.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225049\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/05\/show-dependency-tree.gif\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<p>One more thing. There&#8217;s one more s<span style=\"font-size: 1rem;\">hortcut to add dependencies.\u00a0<\/span><span style=\"font-size: 1rem;\">When editing a POM file, there is a shortcut command to search and add a dependency. Try <\/span><code>Command Palette -&gt; Maven: Add a dependency<\/code><span style=\"font-size: 1rem;\">.<\/span><\/p>\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. You may take this\u00a0<a href=\"https:\/\/www.research.net\/r\/vscodejava-blog?o=%5bo_value%5d&amp;m=%5bm_value%5d\" target=\"_blank\" rel=\"noopener noreferrer\">survey<\/a> to share your thoughts!<\/p>\n<p>Visual Studio Code is a fast and lightweight code editor with great Java support from many extensions<\/p>\n<ul>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-pack\" target=\"_blank\" rel=\"noopener noreferrer\">Java Extension Pack<\/a> includes essential Java tools including <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=redhat.java\" target=\"_blank\" rel=\"noopener noreferrer\">Language Support for Java\u2122 by Red Hat<\/a>, <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-debug\" target=\"_blank\" rel=\"noopener noreferrer\">Debugger for Java<\/a>, <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-maven\" target=\"_blank\" rel=\"noopener noreferrer\">Maven<\/a>, <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-test\" target=\"_blank\" rel=\"noopener noreferrer\">Java Test Runner<\/a> and <a href=\"https:\/\/go.microsoft.com\/fwlink\/?linkid=2006060\" target=\"_blank\" rel=\"noopener noreferrer\">IntelliCode Extension for Visual Studio Code<\/a>.<\/li>\n<li>There&#8217;re also other Java related extensions you can choose from, including\n<ul>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=adashen.vscode-tomcat\" target=\"_blank\" rel=\"noopener noreferrer\">Tomcat<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=SummerSun.vscode-jetty\" target=\"_blank\" rel=\"noopener noreferrer\">Jetty<\/a> for quickly deploy and manage local app servers.<\/li>\n<li>In case you\u2019re working on Spring Boot, there\u2019re also great support provided by <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=Pivotal.vscode-boot-dev-pack\" target=\"_blank\" rel=\"noopener noreferrer\">Pivotal<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-spring-initializr\" target=\"_blank\" rel=\"noopener noreferrer\">Microsoft<\/a> available on Visual Studio Code including <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=Pivotal.vscode-spring-boot\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Boot Tools<\/a>, <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-spring-initializr\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Initializr<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-spring-boot-dashboard\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Boot Dashboard<\/a>.<\/li>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-dependency\" target=\"_blank\" rel=\"noopener noreferrer\">Java Dependencies<\/a> provides you a package view of your Java project and helps you managing your dependencies.<\/li>\n<li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=shengchen.vscode-checkstyle\" target=\"_blank\" rel=\"noopener noreferrer\">Checkstyle<\/a> could be handy when you need coherence code style especially cross multiple team members.<\/li>\n<\/ul>\n<\/li>\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>Welcome to April update! Java 12 is now officially supported with Visual Studio Code. We&#8217;d also like to show you some new and helpful code actions now available, along with new features from Debugger, Maven and CheckStyle. Try these new features by installing Java Extension Pack with Visual Studio Code. See below for more details! [&hellip;]<\/p>\n","protected":false},"author":668,"featured_media":226932,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8,15],"tags":[25,19,27,12],"class_list":["post-224941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source","category-vscode","tag-debugging","tag-maven","tag-refactoring","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>Welcome to April update! Java 12 is now officially supported with Visual Studio Code. We&#8217;d also like to show you some new and helpful code actions now available, along with new features from Debugger, Maven and CheckStyle. Try these new features by installing Java Extension Pack with Visual Studio Code. See below for more details! [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/224941","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=224941"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/224941\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/226932"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=224941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=224941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=224941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}