History
- Java
- Based on C and C++
- Developed in 1991 for intelligent consumer electronic devices
- Green Project (According to Gosling, “the goal was … to build a system that would let us do a large, distributed, heterogeneous network of consumer electronic devices all talking to each other.” )
- James Gosling Modified C++
- Named Oak then Java.
- Platform independent
- Interpreted Language
- Intermediate Code (Byte Code)
- Reliable
- Multiple inheritance and Operator overloading removed
- No Pointers because of security reasons
- Built in network support .
- Internet exploded in 1993, saved project
- Reliability
- Security
- Platform Independence
- Java formally announced in 1995
- Now used to create interactive web applications, distributed enterprise application for consumer devices (pagers, cell phones) and much more..
Why Java???
- Portable WORA!!!!!!
- Simple
- “Pure” Object Oriented Language
- Support for Distributed and Web Applications
- Rich Libraries
- Multithreading , Swing , RMI , NET , SQL …..
- Automatic Garbage Collection
- More Robust
- The Java Virtual Machine becomes the common denominator
- Bytecodes are common across all platforms
- JVM hides the complexity of working on a particular platform
Java Platform
- Micro Edition (Java Technology Enabled Devices)
- Standard Edition (Java Technology Enabled Desktop) & (Workgroup Server)
- Enterprise Edition (Workgroup Server) & (High End Server)
JAVA vs Other Programming Languages
- Similar to C/C++ in syntax
- In-fact Java is C++ minus
- operator overloading
- direct pointer manipulation or pointer arithmetic
- multiple inheritance
- Destructors (Garbage Collector– handles memory automatically)
- No Templates
- Header/make files
- Lots of other things which make Java more attractive.
Object-Oriented
- Fundamentally based on OOP
- All functions belong to classes or objects. No global variables or functions exist
- All classes by default inherit from a common ancestor known as “Object”
- “Almost” all data types are objects
- OOP will be covered in a little more detail later.
Distributed / Network Oriented
- Java grew up in the days of the Internet
- Inherently network friendly
- Original release of Java came with Networking libraries
- Newer releases contain even more for handling distributed applications
- RMI, Transactions
Support for Web and Enterprise Applications
- Given below are some of the Java technologies that can be used for web and enterprise application development
- Servlets
- JSP
- Applets
- JDBC
- RMI
- EJBs
- JSF
Robust / Secure / Safe
- Designed with the intention of being secure
- No pointer arithmetic or memory management!
- The JVM “verifier”
- Checks integrity of byte-codes
- Dynamic runtime checking for pointer and array access
- No buffer overflow bugs!
- SecurityManager to check which operations a piece of code is allowed to do
- “Sandbox” operation for applets and other untrusted code
- Limited set of operations or resources made available
- Contrast to ActiveX
- Rich Set of Libraries
- Multithreading
- Swing
- Regular Expression
- NET
- SQL
- Util
- Serialization
Java Programmer Efficiency
- Faster Development
- More programmer friendly
- Less error prone
- OOP
- Easier to manage large development projects
- Robust memory system
- No pointer arithmetic and manual memory management. Garbage collector!
- Libraries
- Re-use of code
Disadvantages
- Java performance IS slower than C/C++
- Tradeoff between development time vs. run time
- Additional checks in Java which make is secure and robust and network aware etc, all have a small cost.
- JIT compilation and HotSpot
- Dynamic compilation of bytecode to native code at runtime to improve performance
- HotSpot optimizes code on the fly based on dynamic execution patterns
- Can sometimes be even faster than compiled C code!
- Increasing processing speeds helps in overcoming this short fall
Some Sample Java Based Applications
- Hubble Space Telescope Monitoring
- Mars Pathfinder Mission Simulator
- IntelliBrain™ -Bot
- Star Office 5.2
- Web Based
School Management System
Writing Basic Java Program
- For the start following software will do the job
- You need to have the latest version of JDK. (J2SE ) You can download it for free from
- http://java.sun.com/j2se/
- A little older versions such JDK
- Notepad / or Other Modern Intelligent Text Editor
- And you should set your path variable.
Example
/* The HelloWorldApp class implements an application that simply displays “Hello World!” to the standard output. */
public class HelloWorldApp {
public static void main(String[] args) {
//Display the string. No global main
System.out.println(“Hello World!”); }
}
Compiling and Running the program
- Save this file in some directory and compile it using
- javac HelloWorldApp.java
- Run the compiled file by using the command
- java HelloWorldApp
Java Program Development and Execution Steps
Java Systems
Consist of environment, language, Java Applications Programming Interface (API)
Java programs have five phases
- Edit
.java extension
- Compile
javac command: javac MyProgram.java
Creates .class file containing bytecodes with similar name
- Loading
Class loader transfers .class file into memory
Classes loaded and executed by interpreter with java command
To load, appletviewer Welcome.html
OR
java MyProgram
- Verify
Bytecode verifier makes sure bytecodes are valid and do not violate security
- Execute
Computer interprets program one bytecode at a time
Performs actions specified in program.
Learn More:
For solution, online support and query email us at .