Basic Java Programming Tutorial

The JDK, Objects, Classes, and Methods

© Ana Mills

Nov 20, 2008
Java, Ana Mills
Save time and confusion by mastering several basic concepts before diving into Java, including what makes Java unique, installing Java, and basic parts of a Java program.

The Java programming language is very widespread and can be used to create dynamic websites, games, and software. Java development skills are in high demand and learning the language is an enriching experience. This Java tutorial introduces several topics needed to have practical knowledge for the future.

Java itself is not simple to learn, and many would caution against choosing it for a first language. Familiarity with other programming languages like C or C++ would be helpful, but only basic computer skills like installing software are needed.

Getting Started with Java

What makes Java different? The first answer given is usually the compiler versus interpreter explanation. All modern programming languages need a translator to interpret Java commands into those that can be read by the computer. A compiler translates inserted commands into source code and creates an executable that can be used only on that type of computer.

An interpreter, however, translates and executes each line of code at the same time and the resulting program can be used on most modern computers. Java uses an interpreter named the Java Virtual Machine, or JVM. Interpreted programs are portable between most computers, but the trade off is a slower-running program.

Installing Java

In order to learn Java programming, several prerequisites must be noted:

  • Download the Java Development Kit, which contains the Java Virtual Machine discusses earlier.
  • An Integrated Developer Environment is also recommended and many are offered free on the Web, like NetBeans.
  • Developing Java programs using only the JDK and a text editor is possible, but the average beginner will find it easier to use an IDE for now.

The Basic Parts of a Java Program

A few more concepts must be introduced before learning the mechanics of the Java programming language. Many are common to modern programming languages and only require learning once.

Java is object-oriented, which means that a Java program is divided into chunks called objects. An analogy for objects is a business is divided into self-contained departments that perform a unique function. Contrasted with object-oriented programming are procedural languages, which break the entire process into a long series of steps rather than objects.

All Java programs contain a class, the basic blue print needed by the JVM and the computer to run the program. A class is introduced with its declaration word and its name, followed by a set of curly braces: "class uniqueName{}" for example.

The class body contains all of the commands and methods that make a program work. A method is the actual step-by-step instructions for the computer, and all Java desktop applications must contain a special main method. Java applets need not contain a main method, however.

Summary

The Java programming language is not simple to learn, so don't be in a hurry to learn everything at once. Understanding concepts like interpreters versus compilers, basic object-oriented programming languages, and the basic parts of a Java program should be emphasized in the beginning to create a strong programmer in the future. Move on to more advanced Java programming tutorials only once these concepts have been mastered.


The copyright of the article Basic Java Programming Tutorial in Javascript/Java Programming is owned by Ana Mills. Permission to republish Basic Java Programming Tutorial in print or online must be granted by the author in writing.


Java, Ana Mills
       


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo