Your first Java application, "Hello World"

Author
By Darío Rivera
Posted On in Java

The first application of any programmer in any programming language should be the typical "Hello World". Actually, this has more of a historical connotation than a pedagogical one, it's a quick way to feel the excitement of seeing our code running and that we can do great things with a computer. After learning your first language, maybe it's not the same to develop your first "Hello World" in the next language, but you will surely remember that feeling when you did it for the first time. Without further ado, let's make our first "Hello World".

Step 1

Create a folder for your project, you can call it HelloWorld and create the following directory structure in it.

mkdir -p src/com/company
mkdir bin

Step 2

Create a file called Hello.java in src/com/company with the following content.

package com.company;

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

Step 3

To convert the file to bytecodes, run the following command.

javac src/com/company/Hello.java -d bin

This command will look for all class definitions in src and compile them into the bin folder.

Step 4

Run the compiled file with the java command.

cd bin
java com.company.Hello

Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.