Introduction to JAVA Programming
About Java:
Object Oriented Programming Language
Open source software
Developed by James Gosling, Mike Sheridan, and Patrick Naughton
Previously named OAK
It was owned by Sun Microsystems in 1991
It was then taken over by Oracle in 2010
Internet games apps use Java.
Characteristics of Java:
WORA (write once run anywhere) - Platform Independent
Light weight code – Big and useful applications can be created with very light
code
Object Oriented Programming language – near to real world
Built in graphics (Graphics class) – Java offers many built-in graphic features
Supports multimedia (Java APIs) – Java is ideally suited for integration of video,
audio, animation and graphics in Internet environment.
Secure – Java offers many security features that makes its programs safe and
secure
Character Set of Java:
o ASCII codes/Unicode:
- A – Z (65 – 90)
- a – z (97 – 122)
- 0 – 9 (48 – 57)
- Space (32)
o ASCII – American Standard Code for Information Interchange
Ordinary Compilation Process:
The source code is compiled by the compilers for the specific operating systems
(Windows, Macintosh, Unix) and then becomes the machine code for the specific
operating systems (Windows, Macintosh, Unix).
Java Compilation Process:
The source code is compiled by the Java compiler into Java Byte Code, which is
then interpreted by Java interpreters for specific operating systems (Windows,
Macintosh, Unix).
Byte Code:
A Java program (source code) is compiled by the Java Compiler into Java Byte
Code. It is the intermediate code.
The byte code is the same on every platform. Hence, it is also known as the
portable code.
The byte code is then interpreted by a special Java interpreter for a specific
platform, that translates it to the native code of the host machine and executes.
Java Virtual Machine:
o The Java Virtual Machine (JVM) is a platform specific interpreter for the byte
code.
o JVM translates the byte code into the native language of the host machine and
executes.
Portability of Java:
Java is said to be portable as it allows programmers to write codes that could
run on any platform without the need for rewriting or recompilation for each
separate platform.
The byte code and JVM make this possible.
The Java Virtual Machine (JVM) interprets compiled Java bytecode for a
computer’s processor (or hardware platform) and translates into the native code
and executes it.
Compilation, Interpretation, and Execution of Java Programs:
- Java requires an editor to create the source program. The program written using
the editor has to have the same name as that of the defined class within the
program.
- All programs written in Java must have the extension “java”.
- The execution of the Java application program is made through the combination
of compilation and interpretation.
- The Java compiler is a file called javac. After compilation, a file with the
secondary name class is created. This is called as the Byte Code.
- The Java interpreter is a file called java. It interprets the class file and executes
it.
Stand Alone Applications:
Are programs that can run on any platform independently without requiring any
software.
Includes customized software applications or generalized software applications
like word processors, spreadsheets, etc. that run on any platform like Windows,
Linux or Mac OS.
Internet Applets:
A Java applet is a small application which is written in Java, compiled to Java
bytecode and executed when the user launches the Java applet from a web
page, within a Java Virtual Machine (JVM).
How does Java have Light Weight Code?
o A lightweight programming language is one that is designed to have very small
memory footprint, is easy to implement (important when porting a language),
and /or has minimalist syntax and features.
Why is Java a Secure Language?
Jave compiler converts the Java code into byte code (.class file) and these byte
codes are then run by Java Virtual Machine (JVM).
JVM is an interpreter which in installed in each client machine that is updated
with latest security updates by internet.
When these byte codes are executed, the JVM can take care of the security. So,
Java is said to be more secure than other programming languages.
How does Java support multimedia?
- Java Multimedia APIs like:
o Java 2D
o Java 3D
o Java Sound
o Java Speech
o Java Telephony
- API – Application Programming Interface
- Eg. Waiter is a messenger
BlueJ:
BlueJ is basically an IDE (Integrated Development Environment) for Java.
It allows the user to edit, compile, interpret and debug the Java Programs.