Java: Build and run java program like an executable

This entry is part 2 of 54 in the series Learn Java

From Netbeans, we can build the project as a executable jar file.  As a java program runs on top of a Java Virtual Machine (JVM), you need to ensure that JVM is installed in your PC.

From the Netbeans, click on Run -> Build Project (F11).

Once the project is built, a folder called dist will be created.  The jar file will be located inside this directory.

You can run the jar file like:

java -jar JavaApplication2.jar


You can use the code below to try out this example
package javaapplication2;

public class JavaApplication2 {

    public static void main(String[] args) {

        System.out.println("Hello. Greeting from the Console");
Series Navigation<< Java: Netbeans IDE
Java: Swing >>

3 thoughts on “Java: Build and run java program like an executable

Leave a Reply