The Genesis (origin) of Java
Sun Microsystems software engineer Patrick Naughton (1990) had an
impossible job of making different software APIs for different platforms. It was
impossible. He wanted to quit & join NEXT as SUN was a mess.
CEO , Scott McNealy wanted a solution.
Jan 1991, “the Green project” was formed, they made different consumer
electronic products. VCR, Laser Disks etc were made with different CPUs- they
needed special programming.
James Gosling, age 36 first chose C++ for this purpose but it was incapable of
doing what he wanted. So he started modifying C++ (which was a direct descendant
of C programming).
Gosling wrote a new language, named it after a tree outside his window- Oak
Oak had to be: small, platform independent, object oriented.
Jan 1995- Oak becomes Java. By this time Internet had taken off, & Sun
realized the needs of the web exactly matched the characteristics of Java.
23rd March 1995- java had not yet been officially released; it was spreading
like wildfire among developers. San Jose Mercury News reported – “Hot Java will
give you a lift!”
23rd May 1995- Sun world conference announced that “Java is real!” At that
time the entire Java team had only 30 members.
Java’s major advantages over C & C++
Pointers were a major source of bugs in C & C++. Gosling omitted
pointers entirely from Java.
(Actually pointers are still an important part of the language; all objects are
referenced by pointers, but the language handles them, not the programmer) Implicit Garbage Collection. Built-in security.
Java architecture
Java’s architecture comes from four separate but intertwined technologies: The Java Programming Language The Java class file format The Java API (Application Programming Interface) The Java Virtual Machine.
Source programs are written in the Java Programming Language, all
procedural codes fall within methods, programs are compiled into Java class
files, and classes run in the Java Virtual Machine.
When a java program runs, it is assisted by the other classes in Java- API
Example: Object.class, String.class, Calendar.class
The Java platform is unique because it can work without modification on Any platform Any OS if that platform has a Java Virtual Machine
Computing platform:
In computing, a platform describes some sort of hardware architecture
or software framework (including application frameworks), that allows
software to run. Typical platforms include a computer's architecture, operating
system, programming languages and related runtime libraries or graphical user
interface.
Java Virtual Machine
Comparison of a typical procedural program with a Java program: In a typical C program, the source code is compiled into a native
machine language module that consists of 0s and 1s. The Machine Language is specifically tailored to one OS- Wintel,
Mac, Unix or MVS. Therefore it is impossible for one object module to be portable
between platforms. A Java program is NOT compiled into native Machine Language.
Instead, Java makes bytecode.
Java makes a single, universal bytecode module that fits into any
Java Virtual Machine. Each OS has its own different implementation of JVM The JVM sets up its own world within your RAM. The JVM creates an internal sub-computer within the OS ! The bytecode talks to the JVM and the JVM talks to the OS.
(End-users commonly use a Java Runtime Environment (JRE) installed on their own
machine for standalone Java applications, or in a Web browser for Java applets.)
Thus we get the concept of software reuse: “WRITE ONCE RUN ANYWHERE”
Java source code ‡ Java bytecode ‡ [ JVM- win, JVM-Mac, JVM-Unix, JVM-IBM]
Security & the Sandbox
C & C++ are fast because they do not do things like checking array
bound, rather they walk off the edge of the array & invade the memory space beyond.
-- Hackers love that about C & C++
Another weakness is- Buffer overflow. Hacker floods too much data into a buffer.
Java solves this problems: Java checks Array boundaries Java halts Buffer overflow Java Garbage collection gets rid of objects that are no longer used. Java compiler checks to make sure the code is safe before it runs. All code- both local & remote, must pass the Security model.
5 steps of writing a Java program:
1. write it in a text editor
2. Compiler creates bytecode
3. Class loader places the .class file in the memory
4. Bytecode verifier makes sure that the code adheres to Java’s
security rules.
5. JVM interpreter reads bytecode & makes platform native code.
Thinking about Objects:
An object in the real world has-
Attributes: its qualities &
Behaviors: what it does.
Java encapsulates Data (attributes) and Methods (behaviors) into a unit
called an object.
Java takes advantage of similar objects & groups them.
Class: The combination of data variables and methods.
To program in Java, you must: Learn the language and Learn the Class Libraries- APIs.
API greatly simplifies your job as a programmer.
They help you to write complex programs quickly.
To master in Java, you must master in these class libraries.
Declaration & Access Control
Certification objective: Declare Classes & Interfaces Develop Interfaces & Abstract Class Use Primitives, Arrays, Enums & legal Identifiers Use Static Methods, JavaBeans naming & Var-args
Inheritance: ??
Encapsulation: ??
Legal Identifiers
Identifiers can begin with a letter, an underscore, or a currency character.
After the first character, identifiers can also include digits.
Identifiers can be of any length.
int _a; int :b;
int $c; int -d;
int ______2_w; int e#;
int _$; int 7g;
int this_is_a_very_detailed_name_for_an_identifier;
JavaBeans methods must be named using camelCase, and depending on the
method's purpose, must start with set, get, is, add, or remove.
public void setMyValue(int v)
public int getMyValue()
public boolean isMyStatus()
public void addMyListener(MyListener m)
public void removeMyListener(MyListener m)
Source File Declaration Rules
Declaring classes, import statements, and package statements in a source file: There can be only one public class per source code file. Comments can appear at the beginning or end of any line in the source code file
impossible job of making different software APIs for different platforms. It was
impossible. He wanted to quit & join NEXT as SUN was a mess.
CEO , Scott McNealy wanted a solution.
Jan 1991, “the Green project” was formed, they made different consumer
electronic products. VCR, Laser Disks etc were made with different CPUs- they
needed special programming.
James Gosling, age 36 first chose C++ for this purpose but it was incapable of
doing what he wanted. So he started modifying C++ (which was a direct descendant
of C programming).
Gosling wrote a new language, named it after a tree outside his window- Oak
Oak had to be: small, platform independent, object oriented.
Jan 1995- Oak becomes Java. By this time Internet had taken off, & Sun
realized the needs of the web exactly matched the characteristics of Java.
23rd March 1995- java had not yet been officially released; it was spreading
like wildfire among developers. San Jose Mercury News reported – “Hot Java will
give you a lift!”
23rd May 1995- Sun world conference announced that “Java is real!” At that
time the entire Java team had only 30 members.
Java’s major advantages over C & C++
Pointers were a major source of bugs in C & C++. Gosling omitted
pointers entirely from Java.
(Actually pointers are still an important part of the language; all objects are
referenced by pointers, but the language handles them, not the programmer) Implicit Garbage Collection. Built-in security.
Java architecture
Java’s architecture comes from four separate but intertwined technologies: The Java Programming Language The Java class file format The Java API (Application Programming Interface) The Java Virtual Machine.
Source programs are written in the Java Programming Language, all
procedural codes fall within methods, programs are compiled into Java class
files, and classes run in the Java Virtual Machine.
When a java program runs, it is assisted by the other classes in Java- API
Example: Object.class, String.class, Calendar.class
The Java platform is unique because it can work without modification on Any platform Any OS if that platform has a Java Virtual Machine
Computing platform:
In computing, a platform describes some sort of hardware architecture
or software framework (including application frameworks), that allows
software to run. Typical platforms include a computer's architecture, operating
system, programming languages and related runtime libraries or graphical user
interface.
Java Virtual Machine
Comparison of a typical procedural program with a Java program: In a typical C program, the source code is compiled into a native
machine language module that consists of 0s and 1s. The Machine Language is specifically tailored to one OS- Wintel,
Mac, Unix or MVS. Therefore it is impossible for one object module to be portable
between platforms. A Java program is NOT compiled into native Machine Language.
Instead, Java makes bytecode.
Java makes a single, universal bytecode module that fits into any
Java Virtual Machine. Each OS has its own different implementation of JVM The JVM sets up its own world within your RAM. The JVM creates an internal sub-computer within the OS ! The bytecode talks to the JVM and the JVM talks to the OS.
(End-users commonly use a Java Runtime Environment (JRE) installed on their own
machine for standalone Java applications, or in a Web browser for Java applets.)
Thus we get the concept of software reuse: “WRITE ONCE RUN ANYWHERE”
Java source code ‡ Java bytecode ‡ [ JVM- win, JVM-Mac, JVM-Unix, JVM-IBM]
Security & the Sandbox
C & C++ are fast because they do not do things like checking array
bound, rather they walk off the edge of the array & invade the memory space beyond.
-- Hackers love that about C & C++
Another weakness is- Buffer overflow. Hacker floods too much data into a buffer.
Java solves this problems: Java checks Array boundaries Java halts Buffer overflow Java Garbage collection gets rid of objects that are no longer used. Java compiler checks to make sure the code is safe before it runs. All code- both local & remote, must pass the Security model.
5 steps of writing a Java program:
1. write it in a text editor
2. Compiler creates bytecode
3. Class loader places the .class file in the memory
4. Bytecode verifier makes sure that the code adheres to Java’s
security rules.
5. JVM interpreter reads bytecode & makes platform native code.
Thinking about Objects:
An object in the real world has-
Attributes: its qualities &
Behaviors: what it does.
Java encapsulates Data (attributes) and Methods (behaviors) into a unit
called an object.
Java takes advantage of similar objects & groups them.
Class: The combination of data variables and methods.
To program in Java, you must: Learn the language and Learn the Class Libraries- APIs.
API greatly simplifies your job as a programmer.
They help you to write complex programs quickly.
To master in Java, you must master in these class libraries.
Declaration & Access Control
Certification objective: Declare Classes & Interfaces Develop Interfaces & Abstract Class Use Primitives, Arrays, Enums & legal Identifiers Use Static Methods, JavaBeans naming & Var-args
Inheritance: ??
Encapsulation: ??
Legal Identifiers
Identifiers can begin with a letter, an underscore, or a currency character.
After the first character, identifiers can also include digits.
Identifiers can be of any length.
int _a; int :b;
int $c; int -d;
int ______2_w; int e#;
int _$; int 7g;
int this_is_a_very_detailed_name_for_an_identifier;
JavaBeans methods must be named using camelCase, and depending on the
method's purpose, must start with set, get, is, add, or remove.
public void setMyValue(int v)
public int getMyValue()
public boolean isMyStatus()
public void addMyListener(MyListener m)
public void removeMyListener(MyListener m)
Source File Declaration Rules
Declaring classes, import statements, and package statements in a source file: There can be only one public class per source code file. Comments can appear at the beginning or end of any line in the source code file
No comments:
Post a Comment