Introduction To Java

Requirements:
Linux Distribution
Java Development Kit (JDK)
Java Runtime Environment (JRE)
A Shell Interface

My Setup:
Debian GNU/Linux
javac
BASH

The Java programming language was developed by Sun Microsystems Inc in 1991. It later bought by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a class-based object oriented programming language which runs on top of a virtual machine. Java aims on being platform independent (write once run anywhere). A Java program consists of a main class with a public static void main function which serves as an entry point into the program. On top of the main class, you can create packages of other classes to import into your source code . I start off by showing an example of a simple hello world example:

/*
This Is a multi-line comment
*/
public class helloworld{
  public static void main(String[] args){
    System.out.println("Hello World!"); //This is a single line comment
    }
}

I use the “public” keyword to allow public access to this class , as well as the method (class functions in Java are considered methods). In java, there are three FileStreams that act as input and output streams. These are System.in , System.out , and System.err . These FileStreams have a function which allows you to print to the screen. These are initialized by the runtime.

Lets run this :

clim@debian:~/Desktop/cspcsite/JavaTutorials/examples/1$ javac helloworld.java
clim@debian:~/Desktop/cspcsite/JavaTutorials/examples/1$ java helloworld
Hello World!
clim@debian:~/Desktop/cspcsite/JavaTutorials/examples/1$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s