2. BEGINNINGS
…
• the announcement about Java (and the HotJava browser,
which did not enjoy quite the same success) was made
publicly on May 23rd, 1995, the first official release of the
JDK was on January 23rd, 1996.
• Java celebrated its quarter century birthday on May 23,
2020. Started by James Gosling in 1995
• While Gosling was employed by Sun Microsystems, Java was
originally created for interactive television and devices such
as cable boxes and televisions.
• Given that the television industry was too immature to
support Java-based technologies in 1995,
• Sun Microsystems determined that Java's support for
internet protocols such as HTTP rendered it more suitable
for internet-based applications.
3. CONTD…
• Java provides a framework for the development of distributed applications
and can be used to create applications that run either on servers and
clients within a network, or on a single computer.
• Today, Java is used to develop web applications, mobile applications,
desktop applications embedded systems, web servers and application
servers, enterprise applications and scientific applications.
• Oracle frequently likes to quote the statistic that there are “nine million”
Java developers in the world.
• Note that Java was initially the product by Sun MicroSystems, on January
27,2010 Oracle brought Sun MicroSystems and hence its product Java was
inherited by Oracle as well.
5. JAVA FOR
EMERGING
TECHNOLOGI
ES
In a worldwide survey of
2500 developers,
IDC asked about the top
five use cases for which
they have used Java for
emerging technologies as
illustrated in Figure:
6. Q: WHY DOES JAVA CONTINUE
TO BE SO POPULAR?
• Practicality
• Backwards compatibility
• Scalability/Performance/Reliability
• Java is a platform Independent
• The Byte Code
• Java is Fast
• Java is Portable
7. PRACTICALITY
• James Gosling has described Java as a “blue collar”
programming language.
• It was designed to allow developers to get their job
done with the minimum of fuss, whilst still
enabling developers to pick up someone else’s (or
even their own) code at a later date and understand
what it’s supposed to do.
• Sure, you can write unreadable code in Java, just as
you can in any language, but with good coding
conventions it is more readable than many other
languages.
8. BACKWARDS COMPATIBILITY
• Sun and subsequently Oracle have made huge
efforts to ensure that code written for one
version of Java will continue to run unchanged
on newer versions.
• There’s nothing worse than taking code that
works and having to change it to make it work
on a newer version of the platform. That’s just
wasted time.
9. SCALABILITY/PERFORMANCE/RELIAB
ILITY
• With over twenty years and thousands of man-years of
development, Java is a rock-solid platform thanks to some of the
optimisations made by the JVM using dynamic rather than static
code analysis.
• When it comes to scalability, just look at some of the large
enterprises using Java:
• Twitter (who moved off Ruby-on-Rails to the JVM because RoR
wouldn’t scale),
• Spotify, Facebook, Salesforce, eBay and, of course, Oracle.
Hadoop,
• the basis of most big data projects, are either written in Java and
run on the JVM.
• If you want scalability and performance, Java and the JVM is an
obvious choice.
10. JAVA IS A PLATFORM
INDEPENDENT
• Platform independent means java can run on
any computer irrespective to the hardware and
software dependency.
• Means Java does not depend on hardware
means what type of processor , RAM etc. Java
will run on a machine which will satisfy its
basic needs .
12. THE BYTE CODE
• The Byte Code Concept separates java from all other language.
• As we know Byte Code is set of symbols created by Sun which are
generated after the compilation of Program.
• This byte code is actually encoded source code that human cannot
understand
• Byte code is converted to machine code by Java Runtime
Environment.(JRE)
• This Byte code is executed by java runtime environment which
consist of Byte code loader which loads the byte code into
memory.
• then Byte code verifier ,which verifies the Byte code and look for
any extra symbols and code which does not resembles to the
standards and throws unexpected code away and makes java byte
code error free and secure.
14. JAVA IS FAST
• Java is fast because of JIT compiler.
• Just In Time compiler stores the repeated code
in its cache memory and in byte code where
repeated code is used.
• instead of loading that code again from
memory,
• JIT use it from its cache memory and safe time
and space and make execution fast.
15. JAVA IS PORTABLE
• Due to its Byte code is in Bytes,
• Java program takes very less memory on hard
disk and therefore java technology is Portable.
16. WHAT JAVA TECHNOLOGY CAN DO?
• The general-purpose, high-level Java programming
language is a powerful software platform.
• Every full implementation of the Java platform gives you
the following features:
• Development Tools: The development tools provide
everything you'll need for compiling, running, monitoring,
debugging, and documenting your applications. As a new
developer, the main tools you'll be using are
the javac compiler, the java launcher, and
the javadoc documentation tool.
• Application Programming Interface (API): The API provides
the core functionality of the Java programming language. It
offers a wide array of useful classes ready for use in your
own applications. It spans everything from basic objects, to
networking and security, to XML generation and database
access, and more.
17. JDK EDITIONS
• Java Standard Edition (J2SE)
• J2SE can be used to develop client-side standalone applications or applets.
• Java Enterprise Edition (J2EE)
• J2EE can be used to develop server-side applications such as Java servlets and
Java ServerPages.
• Java Micro Edition (J2ME).
• J2ME can be used to develop applications for mobile devices such as cell
phones.
18. A SIMPLE JAVA
PROGRAM
//This program prints Welcome to Java!
public class Welcome
{
public static void main(String[] args)
{
System.out.println("Welcome to Java!");
}
}
18
19. CREATING AND EDITING USING
NOTEPAD
To use NotePad, type
notepad Welcome.java
from the DOS prompt.
19
20. CREATING, COMPILING, AND
RUNNING PROGRAMS
20
Source Code
Create/Modify Source Code
Compile Source Code
i.e., javac Welcome.java
Bytecode
Run Byteode
i.e., java Welcome
Result
If compilation errors
If runtime errors or incorrect result
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
…
Method Welcome()
0 aload_0
…
Method void main(java.lang.String[])
0 getstatic #2 …
3 ldc #3 <String "Welcome to
Java!">
5 invokevirtual #4 …
8 return
Saved on the disk
stored on the disk
Source code (developed by the programmer)
Byte code (generated by the compiler for JVM
to read and interpret, not for you to understand)
21. COMPILING AND RUNNING
JAVA FROM THE COMMAND
WINDOW
Set path to JDK bin directory
set path=c:Program
Filesjavajdk1.x.xbin
Set classpath to include the current
directory
set classpath=.
Compile
javac Welcome.java
Run
21
22. ANATOMY OF A JAVA
PROGRAM
•Comments
•Reserved words
•Modifiers
•Statements
•Blocks
•Classes
•Methods
•The main method
22
23. COMMENTS
Line comment: A line comment is preceded by two
slashes (//) in a line.
Paragraph comment: A paragraph comment is
enclosed between /* and */ in one or multiple lines.
23
javadoc comment: javadoc comments begin with
/** and end with */. They are used for
documenting classes, data, and methods. They
can be extracted into an HTML file using JDK's
javadoc command.
Three types of comments in
Java.
24. RESERVED WORDS
• Reserved words or keywords are words that have
a specific meaning to the compiler and cannot be
used for other purposes in the program.
• For example, when the compiler sees the word
class, it understands that the word after class is
the name for the class. Other reserved words are
public, static, and void etc.
24
25. MODIFIERS
• Java uses certain reserved words called
modifiers that specify the properties of the
data, methods, and classes and how they can
be used.
• Examples of modifiers are public and static.
• Other modifiers are private, final, abstract, and
protected.
• A public datum, method, or class can be
accessed by other programs.
• A private datum or method cannot be accessed
by other programs.
25
26. STATEMENTS
• A statement represents an action or a sequence
of actions.
• The statement System.out.println("Welcome to
Java!") in the program is a statement to display
the greeting
• "Welcome to Java!"
• Every statement in Java ends with a semicolon (;).
26
27. BLOCKS
27
A pair of braces in a program forms a block
that groups components of a program.
public class Test {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
Class block
Method block
28. CLASSES
• The class is the essential Java construct.
• A class is a template or blueprint for
objects.
• To program in Java, you must understand
classes and be able to write and use them.
• A program is defined by using one or more
classes.
28
29. METHODS
• What is System.out.println?
• It is a method: a collection of statements that
performs a sequence of operations to display a
message on the console.
• It can be used even without fully understanding
the details of how it works. It is used by invoking a
statement with a string argument.
• The string argument is enclosed within
parentheses.
• In this case, the argument is "Welcome to Java!"
You can call the same println method with a
different argument to print a different message.
29
30. MAIN
METHOD
The main method provides the control of
program flow. The Java interpreter executes the
application by invoking the main method.
The main method looks like this:
public static void main(String[] args)
{
// Statements;
}
30