Introduction to Java


For many years, Pascal programming language was the preferred vehicle for use in the introductory and intermediate courses, many students felt that C was too difficult to learn as a first language, Java has now replaced Pascal as a first language to learn in many colleges and universities. Many projects often choose Java over C++ because of the simplicity that Java offers, two main reason are

The Java language has many features for graphics, GUI, multimedia, animation, multithreading, networking but at its core it is a fully object-oriented programming language that uses a structured programming technique.

History of Java

Sun Microsystems funded an internal research project called "Green" in 1991. James Gosling took the best parts of C and C++ and changed the more complicated parts to develop a language called Oak, however this name was already taken, when a group of Sun people visited a coffee shop the name Java was suggested and it stuck. Originally Java was to be used in consumer electronic devices such as microwaves, toasters, etc, however due to the explosion of the world wide web (www) Sun people saw the immediate potential of using Java to create web pages, its formal release was in 1995.

Java is used in software applications, web pages, games, mobile devices, etc.

Structured Programming

Structured programming can be seen as a subset or sub discipline of procedural programming, one of the major programming paradigms. It is most famous for removing or reducing reliance on the GOTO statement. Pascal was used to teach structured programming in the early days,

Java Environment

A Java Environment consists of the following

Java has to go through 5 phases into order to execute a java program

Editor You create Java source code with a text editor such as vi (unix) or notepad (windows), the file will have a .java extension. you can use a IDE (integrated development Environment) such as JCreator, JEdit or eclipse.
Compiler You use the command javac to compile the source code, this checks the syntax and translates the source code into bytecode, the language understood by the java virtual interpreter. A file with a .class extension is created.
Class Load

This phase loads the .class file into memory (the file can either be on disk or copied over a network)

The .class file can be either a application program (run on your computer) or a applet (run within a web browser)

Bytecode Verifier This phase checks that the bytecode meets Java's security restrictions, it enforces very strict rules to protect data on your computer.
Interpreter (Execute) The last phase executes the bytecode one byte at a time, thus performing the action you asked when to created the source code.