MAniX-place.co.uk, The Home of Tux

MAniX-place@Articles

Beginners Guide To Java

What Is Java?
Java is a programming language developed by Sun Microsystems in 1995. It was originally designed for programming small computing devices, but was later adapted by the computer industry as a platform-independent programming language. The JAVA "compiler" produces bytecode that can be interpreted on any platform, and is free to download from Sun and is supported on many platforms including Windows, UNIX/Linux, and Solaris.

What Can Java Be Used For?
Java was originally developed for small devices. Now Java can be found in every corner: PDA's, cell phones, PC's, network devices, ecommerce systems, business applications and many more. Java is platform independent, making it perfect for internet applicatons, as the programs made in it will run on many different types of computer. Java comes in several forms:-



What Is The Syntax Like?

While Java is similar in syntax to the C programming language, it brings with it a unique style of coding. It inherits the general programming features, such as loops, conditions, data types, curly braces, and semi-colon delimited statements. Java is a fully featured Object Oriented Programming (OOP) language. This means that it supports classes, modules, inheritance, polymorphism, and many more OOP features.

An Example Java Program
This is an example of a Java source file. The code should be saved in a text file with a .java extension.

// Classname must be same as filename.
public class test
{
  // Variables
  private static String myText = "Hello, World";
  private static String msg;
  private static int myInt = 10;
  // Main - Where the Action Starts
  public static void main(String args[])
  {
    // Print "Hello, World" to the screen.
    System.out.println("Hello, World\n");
    // Multiplication for each value
    for (int i = 0; i <10; i++)
    {
      // Print Calculations to Screen
      System.out.println(calc(i));
    }
  }
  // Handle the calculations
  public static String calc(int timesBy)
  {
    // Put calculation into string
    msg = myInt + " x " + timesBy + "= " + (myInt * timesBy) + "\n";

    // Return Calculation
    return msg;
  }
}


What Do I Need To Get Started?
Java requires the necessary compiler and a simple ASCII text editor such as Notepad (standard on all Windows machines), or VI, eMacs, Kate, etc. for a UNIX/Linux machine.

Common Java Problems
Java is case-sensitive, meaning that if you name a variable MyVar, you cannot call it as myvar or mYvAr.

Forgetting to close your curly braces is another problem. It helps to indent lines inside curly braces so that the braces are aligned.

Are There Any Free Java Tools I Can Use?
You can download a free Java IDE from the Eclipse website or the NetBeans website. See the Apache's ANT Java Build Tool explanation for an example of how to use this free java build tool which usually is integrated with modern IDEs.

Are There Any Java Tools I Can Buy?
You can find a variety of tools for download in the Java Tools section.

What Does Programmers Heaven Offer Me?
Visit the Java section of the site to see articles on Java as well as source code, developer tools and links to many sites, including tutorials pitched at many different levels. If you need assistance, why not post your question on our friendly and lively Java message boards.

Further Reading

Amazon.com offers quite a few books on Java for you to read. A few that may interest you are: If you're a looking for a few excellent e-books on java that are free, you can try these websites out: There are so many free E-books out there that are Java Based that it isn't funny. But, Many times these books are a little outdated. For instance, Java is now in version 1.4, and some of these books are still talking about previous versions. So, it would be a good to also purchase a more uptodate book as well as having the knowledge that you can read more on the internet.

There are also quite a few tutorials available on the internet. Here are a few of them:

Click me to Return to the Articles>>

My name is MAniX. This is my website... Copyright © 2008 Adam "MAniX" Moreland, under the GNU/GPL

Registered Linux User: #417406

Valid XHTML 1.0 Transitional
View My Guestbook
Sign My Guestbook

View My Stats