2. Objectives
• Explaining Java Technology
• Describe key concepts of Java programming language
• List Java product groups
• Write, compile and execute a simple java program
• Explain the key concepts in a simple program
3. What Java is all about ?
Java was originated by James Gosling, Patrick
Naughton, Chris Warth, Ed Frank, and Mike Sheridan at
Sun Microsystems in 1991. This language was initially
called “Oak” but was renamed “Java” in 1995. Somewhat
surprisingly, the original impetus for Java was not the
Internet! Instead, the primary motivation was the need
for a platform-independent language that could be used
to create software to be embedded in various consumer
electronic devices, such as toasters, microwave ovens,
and remote controls.
4. The Java programming language was designed to be:
Distributed - Java was designed with the distributed environment of the
Internet in mind.
Simple - Java has a concise, cohesive set of features that makes it easy
to learn and use.
Multithreaded - Java provides integrated support for multithreaded
programming.
Object – oriented - Java embodies the modern, object-oriented programming
philosophy.
Secure - Java provides a secure means of creating Internet applications.
Platform-independent - Java is not tied to a specific machine or operating
system architecture.
Portable - Java programs can execute in any environment for which there is a
Java run-time system.
Robust - Java encourages error-free programming by being strictly typed and
performing run-time checks.
5. Java versions
• Java 1.0 released in 1995
• Java 1.1 released in 1997
• Java 2 Platform released in December 1998
• Standard Edition (JDK 1.2)
• JDK 1.3 released in 2000
• JDK 1.4 released in 2002
• JDK 5 released in 2004
• JDK 6 released in 2006
• JDK 7 released in 2011
6. As WWW was becoming popular it was difficult for Sun to
manage whole thing as one platform. So they divided Java
into three different platform.
7. A Simple Java Program
class Example {
public static void main(String args[]) {
System.out.println(“Welcome to Java");
}
}
1. Type this code in a new text document and save in D:workplace as Example.java
2. Open console(DOS) application and give D: and cd workplace .
3. Then issue command javac Example.java. If source file contains no errors
Example.class file will be created.
4. Then issue java Example command to run this program. “Welcome to Java”
should be printed in the console.
8. How it works ?
In the Java programming language, all source code is first written in plain text
files ending with the .java extension. Those source files are then compiled
into .class files by the javac compiler. A .class file does not contain code that is
native to your processor; it instead contains bytecodes — the machine
language of the Java Virtual Machine1 (Java VM). The java launcher tool then
runs your application with an instance of the Java Virtual Machine.
9.
10. • class Example {
This line uses the keyword class to declare that a new class is being defined.
As mentioned, the class is Java’s basic unit of encapsulation. Example is the
name of the class. The class definition begins with the opening curly brace ({)
and ends with the closing curly brace (}).
• public static void main (String args[]) {
This line begins the main( ) method. As mentioned earlier, in Java, a
subroutine is called a method. As the comment preceding it suggests, this is
the line at which the program will begin executing. All Java applications begin
execution by calling main( ). The exact meaning of each part of this line
cannot be given now, since it involves a detailed understanding of several
other of Java’s features. As stated, main( ) is the method called when a Java
application begins.
11. • System.out.println(“Welcome to Java");
This line outputs the string “Welcome to Java" followed by a new line
on the screen.Output is actually accomplished by the built-in println( )
method. In this case, println( ) displays the string which is passed to it. As you
will see, println( ) can be used to display other types of information, too. The
line begins with System.out.