Simple java helloworld.

This is not meant so much to be a tutorial on java  as it is just to get you to be exposed to a tiny bit of code and to learn the process to generate an executable. You can find more code for beginners at:  http://www.geekboots.com/java.

Source: helloworld.java

import java.io.*;
class helloworld
    {
        public static void main(String args[ ])
        {
            /* Display text on the screen */
            System.out.println("Hello World!");
        }
    }

Compile:

$ javac helloworld.java

To run it.

$ java helloworld
Hello World!

Create a jar file: (general executable)

$ jar cvfe helloworld.jar helloworld helloworld.class
added manifest
adding: helloworld.class(in = 426) (out= 291)(deflated 31%)

To run it.

$ java -jar helloworld.jar
Hello World!

Another option:

$ javac helloworld.java
$ java -cp . helloworld
Hello World!



Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.