Developing java apps on VS Code


An integrated development environment (IDE) is a software suite that consolidates basic tools required to write and test software..
For a long time there have been basically 3 big players in the java IDE world: Netbeans, Eclipse and IntelliJ IDEA. According to some surveys IntelliJ IDEA is clearly winning the IDE battle, Eclipse is loosing popularity year over year, and Netbeans is basically hanging.
I personally I am part of the “minority” that uses Netbeans for my java development. There were simple things I liked about Netbeans over its competitors, and even though I tried to use Eclipse or IntelliJ, and I saw they are potentially way better than Netbeans, I was always coming back to my familiar Netbeans no matter what. Why was that? Here is the simple things I am looking for in an IDE:
- syntax highlighting for at least: Java, JavaScript, Html, CSS
- build/test/run project from IDE
- ability to see javadocs directly from IDE
- easy jump from one class to another
- code refactoring assistance
- intelligent code completion

Lots of features are great, but b/c I am using only a handful of those provided features, I rather not have to always dig into overpopulated drop down menus. Remembering shortcut keys will always solve this problem.

Most (all) of my projects are maven/gradle based; I like being able to just open my project directly, not having to import it in some kind of proprietary project format, setup workspaces and install external plugins before I get to work.

Over time I started finding Netbeans getting in the way of my productivity. There were numerous annoyances, small problems popping up all the time. The cause of these problems might by me, my project setup, the frameworks I use, my OS, my all around environment, Netbeans itself or a combination of all the above. The plan was to succomb to pressure and get a IntelliJ license. Everybody uses it, and I am being told it does everything but cooking your breakfast. Al I have to do is adjust my workflow to a new environment, and maybe lear some new shortcuts.

I am a big fan of opensource projects, and not a big fan of subscriptions, licenses and dealing with support. Those were some of the reasons why I did not buy the license after all. Plus I had the community version installed on my machine, but I was still using Netbeans for some reason.

I need to ditch Netbeans, but today as I am writing this, I know that my next IDE will not be IntelliJ (nor Eclipse). And this is b/c I tried Visual Studio Code/.

As their github page says VS Code is a type of tool that combines the simplicity of a code editor with what developers need for their core edit-build-debug cycle. I has powerful developer tooling, like IntelliSense code completion and debugging and gets out of your way.

Sounded good. But … First thing first. You might have noticed that this is a software coming from Microsoft, a company that historically has not been too friendly to the open source world, but they have changed their position/opinion in the last years. (Or have they???).

This product is open source and free for private or commercial use (MIT license). Nice.
Another big plus is the fact that VS Code is multi-platform. All my computers run Linux, so this is an important aspect.

First time you open VS Code, it does feel like you opened a simple editor. Similar layout, color palette, even the nice scrollbar with content preview (minimap) and highligting like the sublime text editor. The only additional thing is an activity bar with a few square icons:
- Explorer
- Search
- Source Control
- Debug
- Extensions

That’s it. Clicking on any of those icons brings in front different panels, often minimalist that are self explanatory, a user that has been previously exposed to a full fledged IDE can just explore and feel rigt at home in no time. I am using git, and the source control section allows me out of the box to see staged/unstaged changes in the current branch + allow to see a graphical diff between my current file and the one on HEAD. Of course there is support for other git operations directly from the UI, that I will probably not use b/c I like to do all my git operations directly in the terminal.

The editor that VS Code uses is a deparate project, have a look at the the Monaco Editor. Looks like it’s implemented in typeScript (typed JavaScript) and it is an editor that can run in a browser. Digging a little into it, I found out that they use Electron a tool which uses blink browser engine (used in chromium) and node.js to allow building cross platform desktop apps with JavaScript, HTML, and CSS (web technologies).

Looks like basic web front end development is supported from the get go, but java development, is supported via additional extensions.
Installing extensions is pretty easy. You just click the extension quick icon on the left bar and search through the market place. I searched for java, and I went with installing the following:
- Red Hat: Language Support for Java(TM) by Red Hat – Java Linting, IntelliSense, formatting, refactoring, Maven/Gradle support and more…
- Microsoft: Debugger for Java – a lightweight Java debugger for Visual Studio Code
- Microsoft: Java Test Runner – Run and debug JUnit or TestNG test cases
- Wei Shen: Tomcat for Java – Debug or run your java war package in Apache Tomcat

!!! Careful with the extensions. It might cause your IDE to become unstable. That’s the reason I tried to stay with the lowest number of installed extensions.
Also I wanted big reputable companies behind the chosen extensions. (The outliner is the Tomcat extension which is community supported).

The java Language Server here is where all the java magic is coming from. Features like auto complete, diagnostics, go to definition, find all references and alike can be found in one of the projects used. Eclipse JDT brings in important features like Java debug support, and annotation processing infrastructure.

I am not going to enumerate the few problems I run into, b/c judging by the release schedule and the amount of contributors, activity and attention this project gets, my issues will be solved in no time. Also the main things I rely on are coming from the Eclipse foundation, they are stable and proved projects. All I can say is that after I installed the java extension, there was absolutely no feature I was missing in an IDE. Here is what I tried/needed.
- open/setup maven project
- clean/build/test maven project
- run/debug independent Junit test
- format file
- run/debug war file on Tomcat
- auto reload jsp code on Tomcat
- InteliSense with all features: code completion, see java doc, jump to, etc
- built in bash terminal
- jump to current file in tree panel
- diff file(s) to HEAD or to other branches
- quickly search and jump to files in project
- highlighting of syntax error in the editor
- code refactoring assistance
- auto import
- generate code (java bean getters/setters)
- problems panel: where I can see my annotated TODO/FIXME + other potential problems

Conclusion. Although this IDE is relative new (about 3 years old), I feel like for me it’s the most suitable IDE I have ever tried. It seemed like it was designed for ease of use, with a minimalist default setup. It has about the right amount of features and it has the 21st century look and feel. It is not there yet, but I will be coming back on each one of the new releases, until I will fully adopt it as my main IDE.