Create your first java application

in your ~/development directory go ahead and create a new file and call it [HelloJavaWorld.java](<http://HelloJava.java>) Notice the Camel Case for the file name is a general construct that Java developers adhere to.

The Complete Java Development Bootcamp  Udemy 🔊 2022-02-01 at 10.47.27.jpg

In every Java application there is 2 parts:

  1. The class keyword
  2. The class name - the class name needs to be the same as the file name.

It’ll look something like this

public class HelloJavaWorld{

}

For now, don’t get tripped up on the public keyword, what you need to know is it exposes this class to other classes. It’s not really doing anything since we only have one.

Next up we have a main() method which is the entry point of our application.

Java starts by looking for the main() method.

Use the java extension we installed earlier by typing main and then selecting the expansion

Screen Recording 2022-02-01 at 11.07.01.gif

What that just spit out was a bunch of boilerplate java that is similar to other languages like dart. It’s necessary for the Java runtime/compiler to have this line as an entrypoint.

Inside of that function that is created (inside of it’s {}) you will want to add the following: System.out.println("Hello World!");

It should look like this:

public class HelloJavaWorld{
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Save your file.

Let’s discuss a little of the line we just created.

println() - prints a message inside it’s parenthesis to the console