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.

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!

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.

原文链接:Getting started with Java

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容