SlideShare a Scribd company logo
Java and the JVM



                Manish Pandit
              IGN Engineering
Java Echosystem
• Java as a programming language
• Java as runtime platform/virtual machine
• Java libraries (collections, database drivers..)
Java the programming language
•   Object Oriented
•   Multi-threaded, Concurrent
•   Strongly typed
•   Garbage collection
•   No multiple inheritance
•   2nd most popular language after C at 16%
IDEs
• Please, no vim, emacs, pico etc. I completely
  get it that you’re rock awesome when you
  code on the command line with these tools.
• The IDEs were built to make you productive.
• I use Eclipse, the team uses IntelliJ IDEA. Both
  are good.
• Use anything as long as it’s a real IDE
Code Organization
•   Package Declaration
•   Imports
•   Class or Interface Declaration
•   Members
    – Class variables
    – Methods
Imports
• To use classes from a binary distribution or
  source
• Can be wildcarded (discouraged)
• Auto cleanup – Eclipse Ctl-Shift-O
• Unused Imports
Packages
• To namespace the Class or Interface
• Act as modules containing groups of Classes or
  Interfaces
• Convention
  – dot-separated
  – com., net., sf., org.
• Can contain subpackages
• Packaging can impact visibility if default scope
  is used.
Classes
• Have to have the same file name as the public
  class
• May or may not be a part of a package
• Can be abstract or concrete and/or final
• Acts as a template to create Objects
Classes
• Have a constructor
  – Can be private (for singletons)
  – Default no-args constructor
  – Objects created by using new

     <T> varName = new <? extends T>(args);
     String myName = new String(“Manish”);
Control Structures
•   if-else
•   for loops
•   ternary operator (: ?)
•    while loops
•   switch/case
•   try/catch/finally
•   break/continue for loop control
Using this
• this provides a reference to the current
  instance
• Static members cannot use this, as they do
  not have instances (think Class, not Object)
Typed Collections and Classes
• Introduced in Java 1.5
• Add strong typing via declaration, so the
  compile time checks can be performed
• Syntax:
           Collection myCollection = new ArrayList<String>();
Annotations
• Declarative programming
  – @SuppressWarnings
  – @Override
  – @Deprecated
• Custom annotations
  – An annotation is an @interface
Threading
• Two ways
  – Implement Runnable Interface
  – Extend Thread class
• In both cases, you put the implementation in a
  method called run()
• A thread is started by instantiating the Thread
  and calling start() on it. Never call run()
  directly.
Concurrent Code
• synchornized method
  – Makes a method thread safe
  – You cannot synchronize a constructor
• synchronized block
  – You can acquire a lock on an object, and write
    your code as synchronized(lock) {…}
  – All synchronized methods of a class use the same
    lock if you use synchronize(this) so be careful!
Exceptions
• Checked
• Runtime
Dependency Injection
• Is used to specify dependencies at runtime,
  which get injected (instantiated, associated)
  on class initialization.
• Popular Frameworks
  – Spring DI
  – Google guice
• Declared via configuration, or annotations
Maven
• Maven (and Ant, and Gradle..) are build tools
  used to manage (large) java projects
• Helps manage dependencies declaratively
• Rich set of plugins to run tests, generate
  javadocs, build sites and artifacts
• Everything comes together in pom.xml file.
JVM
•   A very efficient, tuned virtual machine
•   Runs bytecode
•   Runtime garbage collection
•   Supports monitoring via JMX
•   Concurrent
•   Target VM for Groovy, Scala and Clojure
JVM Memory Model
• Heap
  – Where the instance, static variables and Objects
    go
  – Shared across all threads in the VM
  – Automatically garbage collected
• Stack
  – Where the methods and local variables go
  – Every thread gets its own stack
JVM Performance Management
•   Heap and stack sizes
•   GC algorithm tuning
•   Heap monitoring (jprofiler)
•   Deadlocks
•   JMX (jconsole)
Java Libraries
• Utilities
   – Apache Commons
   – JodaTime
   – Google collections
• Web Frameworks
   – JSF
   – Struts
• Application Frameworks
   – Spring
   – Play! Framework
Common java packages
Package           Description
Java.lang.*       Has the core classes like threading, runtime, Data types..
Java.net.*        Has networking classes and adapters (think URL)
Java.util.*       Hash Collections, Calendar, Time/Locale classes
Java.io.*         Has Stream and Buffer handling classes for I/O
Javax.swing.*     Thick Client (UI) classes
Further reading
• Javadocs
• Java Language Specification
• Wikipedia

More Related Content

What's hot (19)

PPTX
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
DOCX
JDK,JRE,JVM
Cognizant
 
PDF
Basic difference between jdk,jre,jvm in advance java course
Preeti Agarwal
 
PPTX
Java bytecode and classes
yoavwix
 
PPTX
JAVA BYTE CODE
Javed Ahmed Samo
 
PDF
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
PPTX
Java 2
KadarkaraiSelvam
 
PPTX
Intro to java programming
Leah Stephens
 
PDF
Java 8 and Beyond, a Scala Story
Tomer Gabel
 
PPTX
Bccon use notes objects in memory and other useful
Frank van der Linden
 
PPT
JVM- Java Virtual Machine
Manasvi Mehta
 
PPTX
Java For beginners and CSIT and IT students
Partnered Health
 
PPTX
Jvm Architecture
ThirupathiReddy Vajjala
 
PPT
The Economies of Scaling Software
Abdelmonaim Remani
 
PDF
Dynamic Proxy by Java
Kan-Han (John) Lu
 
PDF
Ceylon SDK by Stéphane Épardaud
UnFroMage
 
PPTX
Scala, Play 2.0 & Cloud Foundry
Pray Desai
 
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
JDK,JRE,JVM
Cognizant
 
Basic difference between jdk,jre,jvm in advance java course
Preeti Agarwal
 
Java bytecode and classes
yoavwix
 
JAVA BYTE CODE
Javed Ahmed Samo
 
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
Intro to java programming
Leah Stephens
 
Java 8 and Beyond, a Scala Story
Tomer Gabel
 
Bccon use notes objects in memory and other useful
Frank van der Linden
 
JVM- Java Virtual Machine
Manasvi Mehta
 
Java For beginners and CSIT and IT students
Partnered Health
 
Jvm Architecture
ThirupathiReddy Vajjala
 
The Economies of Scaling Software
Abdelmonaim Remani
 
Dynamic Proxy by Java
Kan-Han (John) Lu
 
Ceylon SDK by Stéphane Épardaud
UnFroMage
 
Scala, Play 2.0 & Cloud Foundry
Pray Desai
 

Viewers also liked (20)

PPTX
Political Cartoon
Amy
 
PPTX
IGN's V3 API
Manish Pandit
 
PPT
Google Chrome OS
Michele Pierangeli
 
PPT
πώς θα δημιουργήσετε ένα σενάριο διδασκαλίας
Christos Gotzaridis
 
PPTX
發音相似度最佳化
jyhuangtc
 
PPT
Acacia Research and Learning Forum Tutorial 2
Acacia Research & Learning Forum 2009
 
PDF
Future Agenda Future Of Connectivity
Future Agenda
 
PDF
Future Agenda Future Of Work
Future Agenda
 
PDF
Pp Kee Guard Web
Kee Safety
 
DOC
Animatic Feedbac Kf
3246
 
PPTX
Tet Powerpoint
Amber08
 
PDF
Future Agenda Future Of Food
Future Agenda
 
PDF
Where Media Meets Mobile May 2010
Hugh Griffiths
 
PPTX
Tuinwedstrijd 2 inzending van LittleMissLien
LittleMissLien
 
PDF
Future Agenda Future Of Water
Future Agenda
 
PDF
Phpカンファレンス関西2011 lt
Kaz Watanabe
 
DOC
οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11
Christos Gotzaridis
 
DOC
Filming- Day One
3246
 
PPTX
Compu Lawye Rlucy
Rene WaffleBerry
 
PPTX
20151123 a future resilient – tracking the trends
dbyhundred
 
Political Cartoon
Amy
 
IGN's V3 API
Manish Pandit
 
Google Chrome OS
Michele Pierangeli
 
πώς θα δημιουργήσετε ένα σενάριο διδασκαλίας
Christos Gotzaridis
 
發音相似度最佳化
jyhuangtc
 
Acacia Research and Learning Forum Tutorial 2
Acacia Research & Learning Forum 2009
 
Future Agenda Future Of Connectivity
Future Agenda
 
Future Agenda Future Of Work
Future Agenda
 
Pp Kee Guard Web
Kee Safety
 
Animatic Feedbac Kf
3246
 
Tet Powerpoint
Amber08
 
Future Agenda Future Of Food
Future Agenda
 
Where Media Meets Mobile May 2010
Hugh Griffiths
 
Tuinwedstrijd 2 inzending van LittleMissLien
LittleMissLien
 
Future Agenda Future Of Water
Future Agenda
 
Phpカンファレンス関西2011 lt
Kaz Watanabe
 
οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11
Christos Gotzaridis
 
Filming- Day One
3246
 
Compu Lawye Rlucy
Rene WaffleBerry
 
20151123 a future resilient – tracking the trends
dbyhundred
 
Ad

Similar to Java and the JVM (20)

PPTX
CS8392 OOP
DhanalakshmiVelusamy1
 
PPTX
oop unit1.pptx
sureshkumara29
 
PDF
Core java 5 days workshop stuff
Rajiv Gupta
 
PPT
1- java
Krishna Sujeer
 
PPT
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
PPTX
Beginning Java for .NET developers
Andrei Rinea
 
PPT
Java Tutorial 1
Tushar Desarda
 
PPTX
Unit1 introduction to Java
DevaKumari Vijay
 
PPTX
Core java introduction
Beenu Gautam
 
PPTX
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
PPT
JAVA object oriented programming (oop).ppt
AliyaJav
 
PPT
java-corporate-training-institute-in-mumbai
vibrantuser
 
PPTX
2. Introduction to Java for engineering stud
vyshukodumuri
 
PPTX
01. Introduction to programming with java
Intro C# Book
 
PPT
Introduction what is java
sanjeeviniindia1186
 
PPT
Java01
Sanjeev Tripathi
 
PPT
Java01
mosewoodward24
 
PPT
Java01
mosewoodward24
 
oop unit1.pptx
sureshkumara29
 
Core java 5 days workshop stuff
Rajiv Gupta
 
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
Beginning Java for .NET developers
Andrei Rinea
 
Java Tutorial 1
Tushar Desarda
 
Unit1 introduction to Java
DevaKumari Vijay
 
Core java introduction
Beenu Gautam
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
JAVA object oriented programming (oop).ppt
AliyaJav
 
java-corporate-training-institute-in-mumbai
vibrantuser
 
2. Introduction to Java for engineering stud
vyshukodumuri
 
01. Introduction to programming with java
Intro C# Book
 
Introduction what is java
sanjeeviniindia1186
 
Ad

More from Manish Pandit (20)

PDF
Disaster recovery - What, Why, and How
Manish Pandit
 
PDF
Serverless Architectures on AWS in practice - OSCON 2018
Manish Pandit
 
PDF
Disaster Recovery and Reliability
Manish Pandit
 
PDF
OAuth2 primer
Manish Pandit
 
PDF
Immutable AWS Deployments with Packer and Jenkins
Manish Pandit
 
PDF
AWS Lambda with Serverless Framework and Java
Manish Pandit
 
PDF
AWS Primer and Quickstart
Manish Pandit
 
PPTX
Securing your APIs with OAuth, OpenID, and OpenID Connect
Manish Pandit
 
PDF
Silicon Valley 2014 - API Antipatterns
Manish Pandit
 
PDF
Scalabay - API Design Antipatterns
Manish Pandit
 
PDF
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
Manish Pandit
 
PPTX
API Design Antipatterns - APICon SF
Manish Pandit
 
PPTX
Motivation : it Matters
Manish Pandit
 
PPTX
Building Apis in Scala with Playframework2
Manish Pandit
 
PPTX
Scala at Netflix
Manish Pandit
 
PPT
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Manish Pandit
 
PPT
Evolving IGN’s New APIs with Scala
Manish Pandit
 
PPTX
Object Oriented Programming
Manish Pandit
 
PPTX
Silicon Valley Code Camp 2011: Play! as you REST
Manish Pandit
 
PPTX
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Manish Pandit
 
Disaster recovery - What, Why, and How
Manish Pandit
 
Serverless Architectures on AWS in practice - OSCON 2018
Manish Pandit
 
Disaster Recovery and Reliability
Manish Pandit
 
OAuth2 primer
Manish Pandit
 
Immutable AWS Deployments with Packer and Jenkins
Manish Pandit
 
AWS Lambda with Serverless Framework and Java
Manish Pandit
 
AWS Primer and Quickstart
Manish Pandit
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Manish Pandit
 
Silicon Valley 2014 - API Antipatterns
Manish Pandit
 
Scalabay - API Design Antipatterns
Manish Pandit
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
Manish Pandit
 
API Design Antipatterns - APICon SF
Manish Pandit
 
Motivation : it Matters
Manish Pandit
 
Building Apis in Scala with Playframework2
Manish Pandit
 
Scala at Netflix
Manish Pandit
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Manish Pandit
 
Evolving IGN’s New APIs with Scala
Manish Pandit
 
Object Oriented Programming
Manish Pandit
 
Silicon Valley Code Camp 2011: Play! as you REST
Manish Pandit
 
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Manish Pandit
 

Recently uploaded (20)

PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Digital Circuits, important subject in CS
contactparinay1
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 

Java and the JVM

  • 1. Java and the JVM Manish Pandit IGN Engineering
  • 2. Java Echosystem • Java as a programming language • Java as runtime platform/virtual machine • Java libraries (collections, database drivers..)
  • 3. Java the programming language • Object Oriented • Multi-threaded, Concurrent • Strongly typed • Garbage collection • No multiple inheritance • 2nd most popular language after C at 16%
  • 4. IDEs • Please, no vim, emacs, pico etc. I completely get it that you’re rock awesome when you code on the command line with these tools. • The IDEs were built to make you productive. • I use Eclipse, the team uses IntelliJ IDEA. Both are good. • Use anything as long as it’s a real IDE
  • 5. Code Organization • Package Declaration • Imports • Class or Interface Declaration • Members – Class variables – Methods
  • 6. Imports • To use classes from a binary distribution or source • Can be wildcarded (discouraged) • Auto cleanup – Eclipse Ctl-Shift-O • Unused Imports
  • 7. Packages • To namespace the Class or Interface • Act as modules containing groups of Classes or Interfaces • Convention – dot-separated – com., net., sf., org. • Can contain subpackages • Packaging can impact visibility if default scope is used.
  • 8. Classes • Have to have the same file name as the public class • May or may not be a part of a package • Can be abstract or concrete and/or final • Acts as a template to create Objects
  • 9. Classes • Have a constructor – Can be private (for singletons) – Default no-args constructor – Objects created by using new <T> varName = new <? extends T>(args); String myName = new String(“Manish”);
  • 10. Control Structures • if-else • for loops • ternary operator (: ?) • while loops • switch/case • try/catch/finally • break/continue for loop control
  • 11. Using this • this provides a reference to the current instance • Static members cannot use this, as they do not have instances (think Class, not Object)
  • 12. Typed Collections and Classes • Introduced in Java 1.5 • Add strong typing via declaration, so the compile time checks can be performed • Syntax: Collection myCollection = new ArrayList<String>();
  • 13. Annotations • Declarative programming – @SuppressWarnings – @Override – @Deprecated • Custom annotations – An annotation is an @interface
  • 14. Threading • Two ways – Implement Runnable Interface – Extend Thread class • In both cases, you put the implementation in a method called run() • A thread is started by instantiating the Thread and calling start() on it. Never call run() directly.
  • 15. Concurrent Code • synchornized method – Makes a method thread safe – You cannot synchronize a constructor • synchronized block – You can acquire a lock on an object, and write your code as synchronized(lock) {…} – All synchronized methods of a class use the same lock if you use synchronize(this) so be careful!
  • 17. Dependency Injection • Is used to specify dependencies at runtime, which get injected (instantiated, associated) on class initialization. • Popular Frameworks – Spring DI – Google guice • Declared via configuration, or annotations
  • 18. Maven • Maven (and Ant, and Gradle..) are build tools used to manage (large) java projects • Helps manage dependencies declaratively • Rich set of plugins to run tests, generate javadocs, build sites and artifacts • Everything comes together in pom.xml file.
  • 19. JVM • A very efficient, tuned virtual machine • Runs bytecode • Runtime garbage collection • Supports monitoring via JMX • Concurrent • Target VM for Groovy, Scala and Clojure
  • 20. JVM Memory Model • Heap – Where the instance, static variables and Objects go – Shared across all threads in the VM – Automatically garbage collected • Stack – Where the methods and local variables go – Every thread gets its own stack
  • 21. JVM Performance Management • Heap and stack sizes • GC algorithm tuning • Heap monitoring (jprofiler) • Deadlocks • JMX (jconsole)
  • 22. Java Libraries • Utilities – Apache Commons – JodaTime – Google collections • Web Frameworks – JSF – Struts • Application Frameworks – Spring – Play! Framework
  • 23. Common java packages Package Description Java.lang.* Has the core classes like threading, runtime, Data types.. Java.net.* Has networking classes and adapters (think URL) Java.util.* Hash Collections, Calendar, Time/Locale classes Java.io.* Has Stream and Buffer handling classes for I/O Javax.swing.* Thick Client (UI) classes
  • 24. Further reading • Javadocs • Java Language Specification • Wikipedia