Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun's Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode which can run on any Java virtual machine (JVM) regardless of computer architecture.
The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun made available most of their Java technologies as free software under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.
Java's design, industry backing and portability have made Java one of the fastest-growing and most widely used programming languages in the modern computing industry. (1)
Lets get Started
So what is Java and how would I start using it?
Java is the free programming language from SUN. It is an object-oriented programming language that has deep roots in the networking technologies.
We're going to need a few tools. The first thing we will need is the Java development API (knows as the JDK [Java Development Kit]). We can get this from SUN's Java site here Java SDK. Under 'Popular Downloads' select '>> Java SE'. Next, select the latest version (as of the time of this Blog it is JDK 6 Update 3). Accept the EULA and download the version that is listed for your OS and install.
Now you dont have to have an IDE, but I strongly recommend it. You can get either of the two most popular free IDE's here Eclipse or Netbeans
Now that we have an IDE and the JDK installed, lets write our first application. No, it's not going to be some magnificent POS or anything cool like that. It's going to be the standard cookie-cutting 'Hello World' application that we all love so well.
all of these blogs will make a basic assumption that you the reader are using the Eclipse IDE
Create a new file and name it HelloWorld.
Inside the code, we will be adding 3 parts.
Constructor; code called when the object is created and before any of the body is executed public HelloWorld(){ }
Business Method; a method that is called within the program to perform any action private void sayHello(){ }
Main; this is where the JVM (Java Virtual Machine) enters the code and begins execution public static void main(String args[]){ }
Now lets add put it all together, your code should look like this
public class HelloWorld{
//This is the constructor, when we create a new instance of the object, this code is executed.
// from here, we will call the private method (meaning it can only be seen (it's scope) by the methods in this class only.
public HelloWorld(){ sayHello();}
// Here we print to the console 'Hello Java World!!!'
private void sayHello(){ Sytem.out.println("Hello Java World!!!");}
//Here is where the JVM enters the code body and we create a new (empty) isntance of the
// the HelloWorld object. This will enter the constructor [public HelloWorld]
public static void main(String args[]){ new HelloWorld(); }
}
Now, compile and run...and your all set.
The output should read
Hello Java World!!!
Your now on your way to developing your very own Java software.
No comments:
Post a Comment