Getting started with Java

Getting started with Java

It’s been many years since I’ve done anything substantial with Java. I’d like to try to do a series of posts to get a feel for the Java ecosystem.

The hello world

Just to start things off, the most simple thing. Hello world along with trying out VSCode w/ Java.

Most of these steps are from https://code.visualstudio.com/docs/java/java-tutorial - so this will be rehash of that, I just want to write it down as I learn better that way.

Install OpenJdk

Oracle is undergoing some changes with licensing for the Java SDK(?) - I won’t pretend to understand that, but it sounds like utilizing the open JDK is the route to go.

Install VSCode and extensions

Install VSCode from https://code.visualstudio.com. After installation, install VSCode extensions (Control + Shift + X):

  • Language Support for Java
  • Debugger for Java
  • Java Test Runner
  • Maven for Java
  • Java Dependency Viewer
  • Java Extension Pack

Lastly, install maven - I’d like to use it from the CLI.

Write some code

I need to get into how Java projects and the like work, but for now, a simple hello world should suffice for this post.

1
2
3
4
5
6
public class HelloWorld {
public static void main(String[] args) {
var helloWorld = "Hello world from Java!";
System.out.print(helloWorld);
}
}

Control F5 that bad boy and then get the output!

Program output

Note I did initially have some VSCode output errors - one related to a missing classpath, and one was complaining about not being able to create a launch.json file.

The missing classpath appeared to be related to the fact that I’m working with a raw .java file, and the secondary error was resolved when I restarted VSCode /shrug.

Next time, I hope to be able to dive into some of the boilerplate and ceremony of Java, so that I can better understand how to get a project up and running from the ground up; or to modify an already existing project.

Photo by takeshi2 on Unsplash.

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×