Programming in Java
5-day workshop
What is Java?
Matt Collison
JP Morgan Chase 2021
PiJ1.1: What is Java
Session overview
What is Java?
• General purpose
• High-level compiled
• Strongly typed object-oriented
Who uses Java?
• popularity TIOBE index
• Java history
Getting started with Java?
• Java download and versions
• The javac Java compiler
• A first Java program - Hello world
What is Java?
Java is a general purpose, high-level, compiled,
strongly typed, object oriented programming language.
1. general purpose
2. high-level
3. compiled
4. strongly typed
5. object oriented
General purpose – WORA
W – Write
O – Once
R – Run
A – Anywhere
How does Java achieve this?
• Java runs in a the JVM (Java Virtual Machine) as part of the JRE.
• JRE – The Java runtime environment is distributed with most modern OSs
and written in C.
• JDK – The Java Development Kit is not the JRE and needs to be downloaded.
1. general purpose
2. high-level
3. compiled
4. strongly typed
5. object oriented
High-level and compiled
1. general purpose
2. high-level
3. compiled
4. strongly typed
5. object oriented
Java
high level and compiled
Language
Java bytes
Ready to run!
JVM
Machine code
High level
Compiled
Object-Oriented
Three types of programming languages:
1. Procedural
2. Object Oriented
3. Functional
1. general purpose
2. high-level
3. compiled
4. strongly typed
5. object oriented
What is Java?
Java is a general purpose, high-level, compiled,
strongly typed, object oriented programming language.
1. general purpose
2. high-level
3. compiled
4. strongly typed
5. object oriented
How popular is Java?
https://www.tiobe.com/tiobe-index/
Java (brief) history
• Originally called Oak after a tree outside James Gosling’s office and
created in 1991.
• Launched as Java by Sun microsystems (now part of Oracle) in 1996.
• Continues to be developed primarily by Oracle
• Named after Java coffee
Java versions
Version Date
JDK Beta 1995
JDK1.0 January 23, 1996
JDK 1.1 February 19, 1997
J2SE 1.2 December 8, 1998
J2SE 1.3 May 8, 2000
J2SE 1.4 February 6, 2002
J2SE 5.0 September 30, 2004
Java SE 6 December 11, 2006
Java SE 7 July 28, 2011
Java SE 8 March 18, 2014
Java SE 9 September 21, 2017
Java SE 10 March 20, 2018
Java SE 11 September 25, 2018
Java SE 12 March 19, 2019
Java SE 13 September 17, 2019
Java SE 14 March 17, 2020
Java SE 15 September 15, 2020
Java SE 16 March 16, 2021
• We’re going to use Java 8
• Unless you’re feeling brave
• The Java SE (Standard Edition)
• There’s also an EE (Enterprise Edition)
Getting started – download/install the JDK
• Install the Java JDK – note this is not just the JRE (Java Runtime
Environment)
• https://www.oracle.com/uk/java/technologies/javase-downloads.html
Getting started – a Java program
• Let’s create a program!
• Open a text editor and
enter the following
program
• Save a…
HelloWorld.java
Getting started – compile and run
• Open a command-line and cd (change directory) to the location of
your file
• Run ls to check HelloWorld is in the current directory
• Compile your program with javac HelloWorld.java
• You should now see HelloWorld.class in the directory
Getting started – run your program
• Finally run your compiled program using:
java HelloWorld
Challenge
1. Change the program to print “Hello Java Workshop”
2. Try passing your program a command-line argument
• System.out.println(“Hello” + args[0])
• java HelloWorld Matt
Learning resources
The workshop homepage
https://mcollison.github.io/JPMC-java-intro-2021/
The course materials
https://mcollison.github.io/java-programming-foundations/
• Session worksheets – updated each week
Additional resources
• Think Java: How to think like a computer scientist
• Allen B Downey (O’Reilly Press)
• Available under Creative Commons license
• https://greenteapress.com/wp/think-java-2e/
• Oracle central Java Documentation –
https://docs.oracle.com/javase/8/docs/api/
• Other sources:
• W3Schools Java - https://www.w3schools.com/java/
• stack overflow - https://stackoverflow.com/
• Coding bat - https://codingbat.com/java

Pi j1.1 what-is-java

  • 1.
    Programming in Java 5-dayworkshop What is Java? Matt Collison JP Morgan Chase 2021 PiJ1.1: What is Java
  • 2.
    Session overview What isJava? • General purpose • High-level compiled • Strongly typed object-oriented Who uses Java? • popularity TIOBE index • Java history Getting started with Java? • Java download and versions • The javac Java compiler • A first Java program - Hello world
  • 3.
    What is Java? Javais a general purpose, high-level, compiled, strongly typed, object oriented programming language. 1. general purpose 2. high-level 3. compiled 4. strongly typed 5. object oriented
  • 4.
    General purpose –WORA W – Write O – Once R – Run A – Anywhere How does Java achieve this? • Java runs in a the JVM (Java Virtual Machine) as part of the JRE. • JRE – The Java runtime environment is distributed with most modern OSs and written in C. • JDK – The Java Development Kit is not the JRE and needs to be downloaded. 1. general purpose 2. high-level 3. compiled 4. strongly typed 5. object oriented
  • 5.
    High-level and compiled 1.general purpose 2. high-level 3. compiled 4. strongly typed 5. object oriented Java high level and compiled Language Java bytes Ready to run! JVM Machine code High level Compiled
  • 6.
    Object-Oriented Three types ofprogramming languages: 1. Procedural 2. Object Oriented 3. Functional 1. general purpose 2. high-level 3. compiled 4. strongly typed 5. object oriented
  • 7.
    What is Java? Javais a general purpose, high-level, compiled, strongly typed, object oriented programming language. 1. general purpose 2. high-level 3. compiled 4. strongly typed 5. object oriented
  • 8.
    How popular isJava? https://www.tiobe.com/tiobe-index/
  • 10.
    Java (brief) history •Originally called Oak after a tree outside James Gosling’s office and created in 1991. • Launched as Java by Sun microsystems (now part of Oracle) in 1996. • Continues to be developed primarily by Oracle • Named after Java coffee
  • 11.
    Java versions Version Date JDKBeta 1995 JDK1.0 January 23, 1996 JDK 1.1 February 19, 1997 J2SE 1.2 December 8, 1998 J2SE 1.3 May 8, 2000 J2SE 1.4 February 6, 2002 J2SE 5.0 September 30, 2004 Java SE 6 December 11, 2006 Java SE 7 July 28, 2011 Java SE 8 March 18, 2014 Java SE 9 September 21, 2017 Java SE 10 March 20, 2018 Java SE 11 September 25, 2018 Java SE 12 March 19, 2019 Java SE 13 September 17, 2019 Java SE 14 March 17, 2020 Java SE 15 September 15, 2020 Java SE 16 March 16, 2021 • We’re going to use Java 8 • Unless you’re feeling brave • The Java SE (Standard Edition) • There’s also an EE (Enterprise Edition)
  • 12.
    Getting started –download/install the JDK • Install the Java JDK – note this is not just the JRE (Java Runtime Environment) • https://www.oracle.com/uk/java/technologies/javase-downloads.html
  • 13.
    Getting started –a Java program • Let’s create a program! • Open a text editor and enter the following program • Save a… HelloWorld.java
  • 14.
    Getting started –compile and run • Open a command-line and cd (change directory) to the location of your file • Run ls to check HelloWorld is in the current directory • Compile your program with javac HelloWorld.java • You should now see HelloWorld.class in the directory
  • 15.
    Getting started –run your program • Finally run your compiled program using: java HelloWorld
  • 16.
    Challenge 1. Change theprogram to print “Hello Java Workshop” 2. Try passing your program a command-line argument • System.out.println(“Hello” + args[0]) • java HelloWorld Matt
  • 17.
    Learning resources The workshophomepage https://mcollison.github.io/JPMC-java-intro-2021/ The course materials https://mcollison.github.io/java-programming-foundations/ • Session worksheets – updated each week
  • 18.
    Additional resources • ThinkJava: How to think like a computer scientist • Allen B Downey (O’Reilly Press) • Available under Creative Commons license • https://greenteapress.com/wp/think-java-2e/ • Oracle central Java Documentation – https://docs.oracle.com/javase/8/docs/api/ • Other sources: • W3Schools Java - https://www.w3schools.com/java/ • stack overflow - https://stackoverflow.com/ • Coding bat - https://codingbat.com/java

Editor's Notes

  • #5 One of the main advantages of Java is that it’s cross platform (and open source). No vendor lock-in.
  • #6 The JVM is actually written in C
  • #7 Procedural – monolithic largely unstructured start to end step wise implementation of instructions Object-oriented – structured representation of state and functionality executed with careful consideration of representation and variables. Functional – structured and stateless. Everything is a function and there are no variables (only immutable constants) so there are no side effects and programs can be proofed. https://cscalfani.medium.com/so-you-want-to-be-a-functional-programmer-part-1-1f15e387e536
  • #9 Top three for 20 years.
  • #11 Good knowledge for pub quizzes, not so helpful for coding.
  • #13 It’s easier to use Oracle and often people are confused when they download from java.com Check
  • #18 All resources hang from the ELE pages. How many of you have looked through them?