Jive Talking with Visual Studio Code and Java

Visual Studio Code (or VSC) has been around for a few years now. Popular with web developers due to its built-in support for JavaScript and TypeScript, interest in VSC for other languages is growing rapidly.

31-01-2022
Bcorp Logo


Jive Talking with Visual Studio Code and Java

Visual Studio Code (or VSC) has been around for a few years now. Originally it was popular with web developers due to its built-in support for JavaScript and TypeScript. However, interest in VSC for other languages has grown rapidly thanks in part to VSC’s flexible plugin / extension-based architecture. This allows additional functionality and features to ‘extend’ VSC as required by the developer.

Visual Studio Code Marketplace

The VSC marketplace is a one stop shop for such extensions which range from support for programming languages such as Python, Go, C++ etc. to Docker tools, CSV editors, scientific tools such as Protein Viewer right thorough to games such as Chrome Dinosaur Game!

For this blog we are interested in the Java programming Language.

Why Visual Studio Code?

You may well ask ‘why?’, not least as there are several widely used and well-respected IDEs available already for Java. For example, IntelliJ’s IDEA IDE is arguably the current market leader in Java development tools. It is available as both a free to use Community Edition and a paid for Ultimate edition. For most tasks the Community Edition is more than adequate and provides all the features you will generally need. The paid for Ultimate addition does add some nice to have features, such as profiling tools, support for Spring and some database tools but none of these are essential.

As a seasoned Java developer IntelliJ provides an excellent all-round Java IDE which can also be used with numerous other languages such as JavaScript, Go, Scala, Kotlin etc. These languages can either be supported using plugins to the basic IntelliJ IDEA Java IDE or via the customized versions such as IntelliJ’s GoLand. So why consider yet another tool?

Well one reason is that VSC is not actually an IDE, it is a hugely talented and superior editor. As such it is much lighter weight than an IDE and tends not to have all those extras that you hardly ever user, but which can make the IDE more difficult to understand and navigate.

It also tends to require far less system resources than an IDE, in part because it is implemented using non-Java technologies (whereas Java based IDEs often make extensive use of Java itself) and in part because it does possess all the extras that we have come to expect from an IDE.

Another reason is that over the last 12 to 18 months numerous very experienced Java based colleagues have started to rave about VSC as a Java development environment. They have told me how good it is, how much they like it and how I should really give it a go!

Jive Talking with Visual Studio Code and Java


Configuring Visual Studio Code for Java

Out of the box, VSC does not provide support for Java, instead a set of extensions / aka plugins must be installed to provide Java support. The easiest way to do this is to use the ‘Coding Pack for Java’. This is a preconfigured bundle of different extensions comprising:

  • Visual Studio Code itself
  • The Java Development Kit (JDK) for a specific platform
  • A group of extensions suggested by Microsoft that support Java development.

The group of extensions are basically:

  • Language Support for Java by Red Hat which provides Code Navigation, Code Completion, Refactoring, basic Maven and Gradle support, Javadoc hovers and Code snippets etc.
  • Debugger for Java which provides a set of Java debugging tools using the Java Debug Server which extends the Language Support for Java by Red Hat extension.
  • Test Runner for Java which can be used to run and debug JUnit and TestNG tests in Java,
  • Maven for Java which provides project scaffolding and support for driving Maven tooling,
  • Project Manager for Java, which helps manage Java projects within VSC,
  • Visual Studio IntelliCode extension provides assistance for Java (Python and TypeScript/JavaScript) developers, providing insights based on analysis of the code content.

Unfortunately, the ‘Coding Pack for Java’ is only available for Windows and Macs. If you are on a Linux box, then you will have to install each of these components independently or try the ‘Extension Pack for Java’. Although for Linux you will have to provide your own JDK as appropriate for your platform (for example either OpenJDK or the Oracle JDK).

You can also install additional extensions / plugins to meet your specific requirements, such as:

  • Spring Boot Extension Pack (aka Spring Tools 4 for Visual Studio Code). This provides a collection of extensions for working with and deploying Spring Boot applications.
  • Gradle for Java. This VSC extension provides support for Gradle configuration of your Java projects.
  • Checkstyle for VSC which provides the well known Checkstyle for Java within the VSC editor etc.

The result is that you can freely configuration the VSC editor to match your exact requirements, and only those requirements.

This tends to mean that VSC when configured for Java is lighter weight than an equivalent IDE. It will have a smaller memory footprint, use less processor time and be more performant than a full blow IDE.

Configuration Hell

Of course, the downside is that you may well need to do a lot of installation and configuration work yourself. For an organisation it may make it harder to ensure that a standardised development environment is provided for all developers. It may also be more difficult to get commercial support for any issues that may occur.

As a developer who has primarily used a Java IDE of one kind or another for many years, the interface provided in VSC for configuring settings, organising a workspace (a VSC term for a combination of directories and their contents that are being worked on together) is quiet low level, compared to the UI menu or tabbed based interfaces of IDEs.

Summary

In summary then, VSC provides a free, light weight, editor that is a practical alternative to a full blown, heavier weight IDE. However, you may need to make some compromises to use it and there may be a learning curve involved in configuring VSC to meet your exact requirements.


Would you like to know more?

If you found this article interesting you might be interested in our Java training courses.

Share this post on:

We would love to hear from you

Get in touch

or call us on 020 3137 3920

Get in touch