Sie sind auf Seite 1von 4

1-Introduction to Java Language

Java is an Object Oriented Programming Language which derives its syntax from C and its OOP concepts from C++ (it is not compatible with either of them, Java is also similar to C#, originally known as OAK but was renamed as Java in 1995)

By the end of the 1980s and early 1990s, C++ was the language for programmers however it lacked an important features: it had little or no support for web applications

Javas primary motivation was the need for a platform-independent language which could be used to create software to be embedded in various consumer electronic devices

However then Java also took off because of the development of the Web - Since the internet consists of a network of different types of computers, Operating Systems and CPUs the creation of portable programs became a priority

This caused the focus of Java to switch from consumer electronics to internet programming

Traditional Compilation Process

Source Code Compiler Linker Executable Code *.pas *.obj *.exe

Java Compilation Process (i) Compiling Process

Source Code javac compiler Platform Independent Byte Code *.java *.class

(ii) Execution Process

Platform Independent Byte Code java execution *.class #

# is a platform dependent Interpreter which searches for the main() method and executes. Thus the JVM is the interpreter for the byte code.

What is byte code? o The output of a java compiler is not executable code but byte code. o Byte code is a highly optimised set of instructions designed to be executed by the Runtime Java System i.e. JVM (Java Virtual Machine)

o JVM was designed as an interpreter for byte code (i.e. JVM executes the Java program) o Therefore only the JVM needs to be implemented for each platform o The product of a normal high level language compiler (i.e. a .exe program) cannot be run on any CPU (recall that machine code is machine specific) whereas the product of a java compiler (.class) can be run on any machine provided the appropriate JVM is installed. o NB: although details of JVM will differ from platform to platform, they all understand the same Java byte code. Also it is relatively much easier to develop a JVM for a particular machine than a compiler. o Byte code helps in terms of security since on execution the JVM is in control. It prevents a program from generating side effects outside the system by not providing any ways in which it is possible to access resources outside the program itself.

Javas contribution to the internet : o Applets a special type of program that is designed to be transmitted over the internet and automatically

executed by a Java compatible web browser an applet is downloaded on demand. If the user clicks on a link that contains an applet, the applet will be automatically be loaded and run in the browser 3

o Security In order for Java to enable applets to be safely downloaded and executed on the client computer it was necessary to prevent an applet from gaining unauthorised access to system resources. Java achieved this protection by confining an applet to the java execution environment and not allowing it access to other parts of the program This is achieved through byte code

o Portability If a java program was to be run on virtually any computer connected to the internet then there needed to be a way in which the same code works on all computers since it is not practical to have different versions of the program for different computers Portability is also achieved through the use of byte code

Concluding note & Misconceptions about the language

Java is not simply a language which one needs to study for their Alevel but one which is very important in industry

Java is an enormous language it has around 6,000 classes Java is NOT the fastest language

Das könnte Ihnen auch gefallen