SlideShare a Scribd company logo
Introduction to Java Programming - internals
Contents Computer Programming Overview Your First Java Program Java Technology Overview Eclipse IDE
Contents The Structure of Java Programs Keywords and Identifiers Data Types Integral, Textual, Floating-Point Enumerations Variables, Declarations, Assignments, Operators
Contents Expressions and Statements Logical Statements Loop Statements Console Input and Output Arrays and Array Manipulation Using the Java API Documentation
What is Computer Programming?
Define: Computer Programming Computer Programming: creating a sequence of instructions to enable the computer to do something Definition by Google
Programming Phases Define a task/problem Plan your solution Find suitable algorithm to solve it Find suitable data structures to use Write code Fix program error (bugs) Make your customer happy   = Specification   = Design   = Implementation   = Testing & Debugging   = Deployment
Your First Java Program
First Look at Java Code Sample Java Source code: public class HelloJava { public static void main(String args[]) { System.out.println("Hello, Java"); } }
Java Code – How It Works? public class HelloJava { public static void main(String args[]){ System.out.println("Hello, Java"); } } Define a class called " HelloJava " Define the  main()  method – the program entry point Print a text on the console calling the method " println() " of the system's standard output
Java Is Case Sensitive! public class HelloJava { public static void Main(String args[]){ system.out.PrintLn("Hello, Java"); } } The keyword  class  should be lowercase The class  System  should be in  " Pascal Case " The method  println()  should be in  " camel   Case " The correct method name is  main()
Java Code Should Be Well Formatted public class HelloJava { public static void main(String args[])   { System.out.println("Hello, Java"); } } The  {  symbol should be on the same line. The block after the  {  symbol should be indented by a TAB Class names should start with a CAPITAL letter The  {  symbol should be on the same line. The  }  symbol should be under the beginning of the line with corresponding  {
Example of Bad Formatting public  class HelloJava  {public static  void  main(String args[]){ System.out.println ("Hello, Java"); System.out.println("Hello, Java");} } Such formatting makes the code unreadable
File Names Match Class Names! In Java all public classes should be in a file name matching their name For example the class  HelloJava  should be in the file  HelloJava.java public class HelloJava { public static void main(String args[]){ System.out.println("Hello, Java"); } } HelloJava.java
Your First Java Program Live Demo
Welcome to Java Technology
Why Java? Meets the emerging software development challenges of its time Platform independence Run on wide variety of hardware Desktop, server-side, embedded Easier to develop, administer, maintain Object-oriented approach Built-in security Network mobility (mobile code)
History of Java Project “Oak” began in mid 80’s at Sun Microsystems by James Gosling  Java 1.0 – released Jan 1996 Java 1.1 – released Feb 1997 Reflection, inner classes Serialization, AWT, JavaBeans Java 1.2 – released Dec 1998 Also known as "Java 2 Platform" Significant improvement Swing GUI, performance and security improvements
History of Java Java 2 splits -> J2SE, J2EE, J2ME – 1999 J2SE 1.3 – released May 2000 CORBA, RMI, Sound API, many enhancements J2SE 1.4 – released Feb 2002 Assertions, non-blocking I/O, XML parser J2SE 1.5 (5.0) – released Sep 2004 Lots of new language features Generics, enhanced for loop, variable arguments list, auto boxing/unboxing, ... Java SE 6.0 – December 2006 Better performance, scripting support, new APIs
What is the Java Technology? Java technology is: A programming language A development environment An application environment A deployment environment It is similar in syntax to C++ and C# Used for developing applets and applications (standalone, server-side, Web services, mobile, embedded, ...)
Java Platform Architecture
The Java Platform Architecture Consists of four distinct, but interrelated technologies The Java virtual machine (JVM) Class loaders and class files The Java programming language The Java API Writing Java programs is related to all of these technologies
Java, JVM and OS
Java 5 Architecture
Java Compilation and Execution public class HelloJava { public static void main(String args[])   { System.out.println( "Hello, Java"); } } HelloJava.java Compilation 0010011101011101110101110101011101110101101101101110101011010101010101010101010101101110100011010000001011010111101101110101001110100110101010101101011111101010111010100101011101010100101001111101101010101110101010001010101001011000101010011101010100110101110110111110101 HelloJava.class Execution
The Java Programming Environment
Architectural Tradeoffs Not  “the right tool for any job” Platform independence Productivity Execution speed Lowest common subset of features Garbage collection Lack of control of memory management and thread scheduling Dynamic linking Symbolic references Security
Java Platform Editions
Java Platform Editions The Java platform has several editions: J2SE (Java SE) J2EE (Java EE) J2ME
J2SE, J2EE, J2ME Java 2 Standard Edition (J2SE, Java SE) Used to write standalone Java Applications and Applets Java 2 Enterprise Edition (J2EE, Java EE) A set of API’s and server specifications built on top of J2SE Used for building Enterprise, Web applications and Web services Java 2 Micro Edition (J2ME) A pared down version of J2SE and API’s for wireless and embedded devices
Java Virtual Machine (JVM)
The Java Virtual Machine Main features Load class files Execute bytecodes they contain Loose features specification Use any technique to execute bytecode Software/hardware implementation Can be implemented on a wide variety of computers and devices
The Java Virtual Machine JVM provides definitions for the: Instruction set (virtual CPU) Register set Class file format Stack Garbage-collected heap Memory area
Garbage Collection Allocated memory that is no longer needed is automatically deallocated The Java programming language provides a system level thread to track memory allocation Garbage collection: Checks for and frees memory no longer needed Is done automatically Can vary dramatically across JVM implementations
The JVM and Host Operating Systems Java methods Written in Java, compiled to bytecodes Stored in class files ( .class ) Native methods Written in other languages (C, C++, …) Compiled to native machine code Dynamic libraries Java Native Interface (JNI)
The JVM and Host Operating Systems
Classes and Class Loaders
Classes and Class Loaders The “bootstrap” class loader Only one Part of the JVM implementation Loads classes in some default way User-defined class loaders Written and compiled in Java Installed at runtime Load classes in custom ways Not  part of the JVM implementation
Class Loaders Architecture
Class Loaders Load classes over networks, from DB, … Keep track of loaded classes Class namespaces Access between class namespaces Advantages Security Mobility Extensibility
Java Class Files Java   classes, translated to “bytecodes” Stored with  .class  file extension Platform independent binary format Consistent byte order of integers Designed to be compact Network mobility Can be downloaded as needed Dynamic linking
Classpath The CLASSPATH environment variable Third-party and user-defined classes Can be overridden using the “-classpath” Java command-line argument Classpath entries can be Directories Archive files (.jar and .zip) Classes are loaded in the order of appearance
JAR Files Java programs are compiled to  .class  files (Java bytecode + class metadata) Class files are packed in JAR archives JAR files (short for  J ava  AR chive) are Standard ZIP files Can use compression or not Used to distribute a set of compiled Java classes, associated metadata and resources
JAR Files Can be created and extracted with  jar  command line tool Creating  .jar  file: Extracting  .jar  files Can be created and extracted with  WinZip  or other ZIP manipulation tool jar -cf MyJarArchive.jar *.class jar -xf MyJarArchive.jar *.class
Eclipse Compiling,  R unning and  D ebugging  Java P rograms
Creating New Java Application Window    Open Perspective    Java File    New    Project Choose Java Project Choose project name Click Finish
Creating New Java Application (2) File    New    Class Choose the project you just made Choose class name Enable “public static void main (String args[])” check box Click Finish
Eclipse creates some source code for you. Creating New Java Application (3)
Compiling Source Code Compilation process includes: Syntactic checks Type safety checks Translation of the source code to Java bytecode In Eclipse compilation is made automatically As you type, the program is checked for errors and is compiled Saving the file (Ctrl+S) forces compilation
Running Programs Running process includes: Compiling (if project not compiled) Starting the application You can run application by: Using  Run As->Java Application  popup menu * NOTE: Not all types of projects are able to be run!
Debugging The Code Debugging process includes: Spotting an error Finding the code that causes the error Fixing the code Testing to see if the error is gone and no errors are introduced This process is iterative and continuous
Debugging in Eclipse Eclipse has built-in debugger It provides: Breakpoints Ability to trace the code execution Ability to inspect variables at runtime
Eclipse Compiling,  R unning and  D ebugging  Java P rograms  Live Demo

More Related Content

PDF
Basic Java Programming
PPTX
JRE , JDK and platform independent nature of JAVA
PPTX
Core Java Tutorials by Mahika Tutorials
PPTX
Introduction to java
PPTX
Introduction to Spring Boot
PDF
Introduction to java (revised)
PPTX
Presentation on Core java
PDF
Introduction to basics of java
Basic Java Programming
JRE , JDK and platform independent nature of JAVA
Core Java Tutorials by Mahika Tutorials
Introduction to java
Introduction to Spring Boot
Introduction to java (revised)
Presentation on Core java
Introduction to basics of java

What's hot (20)

PPTX
Java Programming
PPTX
1 java programming- introduction
PPTX
Core Java
 
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
PPTX
Core Java
PPTX
Java features
PPTX
Workshop Spring - Session 1 - L'offre Spring et les bases
PDF
Spring boot introduction
PPSX
Exception Handling
PDF
Introduction to Java
PPTX
Java Spring Framework
PPT
Exception Handling in JAVA
PPT
Java features
PPTX
Spring Framework
ODP
Exception Handling In Java
PDF
Java IO
PDF
Spring Boot
PDF
Introduction to Java Programming
PDF
Java11 New Features
PPTX
Introduction to java
Java Programming
1 java programming- introduction
Core Java
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Core Java
Java features
Workshop Spring - Session 1 - L'offre Spring et les bases
Spring boot introduction
Exception Handling
Introduction to Java
Java Spring Framework
Exception Handling in JAVA
Java features
Spring Framework
Exception Handling In Java
Java IO
Spring Boot
Introduction to Java Programming
Java11 New Features
Introduction to java
Ad

Viewers also liked (7)

PPTX
DOC
Palindrome number program in c
DOCX
Industrial Training report on java
PPTX
Internship final presentation
DOCX
Basic java important interview questions and answers to secure a job
PPTX
Java Ring
PPT
Umbrella Branding
Palindrome number program in c
Industrial Training report on java
Internship final presentation
Basic java important interview questions and answers to secure a job
Java Ring
Umbrella Branding
Ad

Similar to Java platform (20)

PPT
Javalecture 1
PPT
Introduction
PPTX
Chapter 2.1
PPTX
1.introduction to java
PPTX
UNIT 1.pptx
PDF
OOPS JAVA.pdf
PPT
INTRODUCTION TO JAVA APPLICATION
PPT
Fundamentals of oop lecture 2
PDF
Introduction java programming
PPTX
2 22CA026_Advance Java Programming_Data types and Operators.pptx
PDF
Java Programming Fundamentals: Complete Guide for Beginners
PPTX
Programming in Java
DOCX
Unit of competency
PDF
Java programming basics
PPT
01slide
PPT
01slide
PPTX
Java introduction
PPTX
Manuel - SPR - Intro to Java Language_2016
Javalecture 1
Introduction
Chapter 2.1
1.introduction to java
UNIT 1.pptx
OOPS JAVA.pdf
INTRODUCTION TO JAVA APPLICATION
Fundamentals of oop lecture 2
Introduction java programming
2 22CA026_Advance Java Programming_Data types and Operators.pptx
Java Programming Fundamentals: Complete Guide for Beginners
Programming in Java
Unit of competency
Java programming basics
01slide
01slide
Java introduction
Manuel - SPR - Intro to Java Language_2016

More from BG Java EE Course (20)

PPT
Rich faces
PPT
JSP Custom Tags
PPT
Java Server Faces (JSF) - advanced
PPT
Java Server Faces (JSF) - Basics
PPT
Unified Expression Language
PPT
Java Server Pages
PPT
Web Applications and Deployment
PPT
Java Servlets
PPTX
HTML: Tables and Forms
PPTX
HTML Fundamentals
PPTX
WWW and HTTP
ODP
JavaScript and jQuery Fundamentals
ODP
Creating Web Sites with HTML and CSS
PPT
Processing XML with Java
PPT
Introduction to XML
PPT
Data Access with JDBC
PPT
Introduction to-sql
PPT
Introduction to-RDBMS-systems
Rich faces
JSP Custom Tags
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - Basics
Unified Expression Language
Java Server Pages
Web Applications and Deployment
Java Servlets
HTML: Tables and Forms
HTML Fundamentals
WWW and HTTP
JavaScript and jQuery Fundamentals
Creating Web Sites with HTML and CSS
Processing XML with Java
Introduction to XML
Data Access with JDBC
Introduction to-sql
Introduction to-RDBMS-systems

Recently uploaded (20)

PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
creating-agentic-ai-solutions-leveraging-aws.pdf
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Event Presentation Google Cloud Next Extended 2025
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
PDF
Top Generative AI Tools for Patent Drafting in 2025.pdf
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PPTX
How to Build Crypto Derivative Exchanges from Scratch.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
REPORT: Heating appliances market in Poland 2024
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Reimagining Insurance: Connected Data for Confident Decisions.pdf
creating-agentic-ai-solutions-leveraging-aws.pdf
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
NewMind AI Monthly Chronicles - July 2025
Event Presentation Google Cloud Next Extended 2025
Smarter Business Operations Powered by IoT Remote Monitoring
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Sensors and Actuators in IoT Systems using pdf
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
Top Generative AI Tools for Patent Drafting in 2025.pdf
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
How to Build Crypto Derivative Exchanges from Scratch.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
CIFDAQ's Market Insight: SEC Turns Pro Crypto
REPORT: Heating appliances market in Poland 2024
GamePlan Trading System Review: Professional Trader's Honest Take
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?

Java platform

  • 1. Introduction to Java Programming - internals
  • 2. Contents Computer Programming Overview Your First Java Program Java Technology Overview Eclipse IDE
  • 3. Contents The Structure of Java Programs Keywords and Identifiers Data Types Integral, Textual, Floating-Point Enumerations Variables, Declarations, Assignments, Operators
  • 4. Contents Expressions and Statements Logical Statements Loop Statements Console Input and Output Arrays and Array Manipulation Using the Java API Documentation
  • 5. What is Computer Programming?
  • 6. Define: Computer Programming Computer Programming: creating a sequence of instructions to enable the computer to do something Definition by Google
  • 7. Programming Phases Define a task/problem Plan your solution Find suitable algorithm to solve it Find suitable data structures to use Write code Fix program error (bugs) Make your customer happy = Specification = Design = Implementation = Testing & Debugging = Deployment
  • 8. Your First Java Program
  • 9. First Look at Java Code Sample Java Source code: public class HelloJava { public static void main(String args[]) { System.out.println("Hello, Java"); } }
  • 10. Java Code – How It Works? public class HelloJava { public static void main(String args[]){ System.out.println("Hello, Java"); } } Define a class called " HelloJava " Define the main() method – the program entry point Print a text on the console calling the method " println() " of the system's standard output
  • 11. Java Is Case Sensitive! public class HelloJava { public static void Main(String args[]){ system.out.PrintLn("Hello, Java"); } } The keyword class should be lowercase The class System should be in " Pascal Case " The method println() should be in " camel Case " The correct method name is main()
  • 12. Java Code Should Be Well Formatted public class HelloJava { public static void main(String args[]) { System.out.println("Hello, Java"); } } The { symbol should be on the same line. The block after the { symbol should be indented by a TAB Class names should start with a CAPITAL letter The { symbol should be on the same line. The } symbol should be under the beginning of the line with corresponding {
  • 13. Example of Bad Formatting public class HelloJava {public static void main(String args[]){ System.out.println ("Hello, Java"); System.out.println("Hello, Java");} } Such formatting makes the code unreadable
  • 14. File Names Match Class Names! In Java all public classes should be in a file name matching their name For example the class HelloJava should be in the file HelloJava.java public class HelloJava { public static void main(String args[]){ System.out.println("Hello, Java"); } } HelloJava.java
  • 15. Your First Java Program Live Demo
  • 16. Welcome to Java Technology
  • 17. Why Java? Meets the emerging software development challenges of its time Platform independence Run on wide variety of hardware Desktop, server-side, embedded Easier to develop, administer, maintain Object-oriented approach Built-in security Network mobility (mobile code)
  • 18. History of Java Project “Oak” began in mid 80’s at Sun Microsystems by James Gosling Java 1.0 – released Jan 1996 Java 1.1 – released Feb 1997 Reflection, inner classes Serialization, AWT, JavaBeans Java 1.2 – released Dec 1998 Also known as "Java 2 Platform" Significant improvement Swing GUI, performance and security improvements
  • 19. History of Java Java 2 splits -> J2SE, J2EE, J2ME – 1999 J2SE 1.3 – released May 2000 CORBA, RMI, Sound API, many enhancements J2SE 1.4 – released Feb 2002 Assertions, non-blocking I/O, XML parser J2SE 1.5 (5.0) – released Sep 2004 Lots of new language features Generics, enhanced for loop, variable arguments list, auto boxing/unboxing, ... Java SE 6.0 – December 2006 Better performance, scripting support, new APIs
  • 20. What is the Java Technology? Java technology is: A programming language A development environment An application environment A deployment environment It is similar in syntax to C++ and C# Used for developing applets and applications (standalone, server-side, Web services, mobile, embedded, ...)
  • 22. The Java Platform Architecture Consists of four distinct, but interrelated technologies The Java virtual machine (JVM) Class loaders and class files The Java programming language The Java API Writing Java programs is related to all of these technologies
  • 25. Java Compilation and Execution public class HelloJava { public static void main(String args[]) { System.out.println( "Hello, Java"); } } HelloJava.java Compilation 0010011101011101110101110101011101110101101101101110101011010101010101010101010101101110100011010000001011010111101101110101001110100110101010101101011111101010111010100101011101010100101001111101101010101110101010001010101001011000101010011101010100110101110110111110101 HelloJava.class Execution
  • 26. The Java Programming Environment
  • 27. Architectural Tradeoffs Not “the right tool for any job” Platform independence Productivity Execution speed Lowest common subset of features Garbage collection Lack of control of memory management and thread scheduling Dynamic linking Symbolic references Security
  • 29. Java Platform Editions The Java platform has several editions: J2SE (Java SE) J2EE (Java EE) J2ME
  • 30. J2SE, J2EE, J2ME Java 2 Standard Edition (J2SE, Java SE) Used to write standalone Java Applications and Applets Java 2 Enterprise Edition (J2EE, Java EE) A set of API’s and server specifications built on top of J2SE Used for building Enterprise, Web applications and Web services Java 2 Micro Edition (J2ME) A pared down version of J2SE and API’s for wireless and embedded devices
  • 32. The Java Virtual Machine Main features Load class files Execute bytecodes they contain Loose features specification Use any technique to execute bytecode Software/hardware implementation Can be implemented on a wide variety of computers and devices
  • 33. The Java Virtual Machine JVM provides definitions for the: Instruction set (virtual CPU) Register set Class file format Stack Garbage-collected heap Memory area
  • 34. Garbage Collection Allocated memory that is no longer needed is automatically deallocated The Java programming language provides a system level thread to track memory allocation Garbage collection: Checks for and frees memory no longer needed Is done automatically Can vary dramatically across JVM implementations
  • 35. The JVM and Host Operating Systems Java methods Written in Java, compiled to bytecodes Stored in class files ( .class ) Native methods Written in other languages (C, C++, …) Compiled to native machine code Dynamic libraries Java Native Interface (JNI)
  • 36. The JVM and Host Operating Systems
  • 37. Classes and Class Loaders
  • 38. Classes and Class Loaders The “bootstrap” class loader Only one Part of the JVM implementation Loads classes in some default way User-defined class loaders Written and compiled in Java Installed at runtime Load classes in custom ways Not part of the JVM implementation
  • 40. Class Loaders Load classes over networks, from DB, … Keep track of loaded classes Class namespaces Access between class namespaces Advantages Security Mobility Extensibility
  • 41. Java Class Files Java classes, translated to “bytecodes” Stored with .class file extension Platform independent binary format Consistent byte order of integers Designed to be compact Network mobility Can be downloaded as needed Dynamic linking
  • 42. Classpath The CLASSPATH environment variable Third-party and user-defined classes Can be overridden using the “-classpath” Java command-line argument Classpath entries can be Directories Archive files (.jar and .zip) Classes are loaded in the order of appearance
  • 43. JAR Files Java programs are compiled to .class files (Java bytecode + class metadata) Class files are packed in JAR archives JAR files (short for J ava AR chive) are Standard ZIP files Can use compression or not Used to distribute a set of compiled Java classes, associated metadata and resources
  • 44. JAR Files Can be created and extracted with jar command line tool Creating .jar file: Extracting .jar files Can be created and extracted with WinZip or other ZIP manipulation tool jar -cf MyJarArchive.jar *.class jar -xf MyJarArchive.jar *.class
  • 45. Eclipse Compiling, R unning and D ebugging Java P rograms
  • 46. Creating New Java Application Window  Open Perspective  Java File  New  Project Choose Java Project Choose project name Click Finish
  • 47. Creating New Java Application (2) File  New  Class Choose the project you just made Choose class name Enable “public static void main (String args[])” check box Click Finish
  • 48. Eclipse creates some source code for you. Creating New Java Application (3)
  • 49. Compiling Source Code Compilation process includes: Syntactic checks Type safety checks Translation of the source code to Java bytecode In Eclipse compilation is made automatically As you type, the program is checked for errors and is compiled Saving the file (Ctrl+S) forces compilation
  • 50. Running Programs Running process includes: Compiling (if project not compiled) Starting the application You can run application by: Using Run As->Java Application popup menu * NOTE: Not all types of projects are able to be run!
  • 51. Debugging The Code Debugging process includes: Spotting an error Finding the code that causes the error Fixing the code Testing to see if the error is gone and no errors are introduced This process is iterative and continuous
  • 52. Debugging in Eclipse Eclipse has built-in debugger It provides: Breakpoints Ability to trace the code execution Ability to inspect variables at runtime
  • 53. Eclipse Compiling, R unning and D ebugging Java P rograms Live Demo