Wednesday, November 18, 2015

How to create java hello world program on Lubuntu


On previous post/article i show you how to install open JDK on lubuntu, now it's time to try creating java program and then compile and run it. So we are going to do little coding here just to make sure the java compiler that we install is really working.

For beginners when we learn new programming language for the first time, we always start with creating a simple program that print/echo to standard output, this simple program is usually a hello world program.

So in this post/article i want to show you how to create a hello world program with java on lubuntu operating system. We are going to need a text editor, for this demo i'm going to use leafpad text editor because that's the default text editor for lubuntu, but feel free to use other text editor such as vi, vim, nano or even gedit.

Step by step how to create hello world java program on lubuntu
  • open terminal/console and type this command to launch leafpad and create a file called HelloWorld.java

  • leafpad HelloWorld.java
  • next copy paste this code on leafpad 

  • public class HelloWorld {
    
        public static void main(String[] args) {
            // Prints "Hello, World" to the terminal window.
            System.out.println("Hello, World");
      	System.out.println("lubuntuhowto.blogspot.com is awesome blog !!");
        }
    
    }

  • now click File > Save 
  • on the terminal compile the java program that we just create

  • javac HelloWorld.java

  • run the hello world program

  • java HelloWorld

  • congratulation you just create your first java program on lubuntu
This just a basic simple java application, if you want to learn more about java programming please comment down below whether i should make another blog post about java programming or not.

No comments:

Post a Comment