SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
Java goes wild 
Lesson 1: Introduction to Java 
Thierry Wasylczenko
After this course ... 
You will: 
• Know what is the JDK/JRE 
• Be able to set up your development environment 
• Know how to compile and run a Java program 
2
Agenda 
• Bascis 
• How does all of this work? 
• Developer’s environment 
3
Basics 
Success is neither magical nor mysterious. Success is the natural 
consequence of consistently applying the basic fundamentals. 
Jim Rohn “ 
4
Basics 
• Source code is inside files with .java extension 
• The source code is compiled into .class files 
• The class files are executed by a strange thing (covered later) 
5
A Java file 
public class Foo { 
public static void main(String[] args) { 
System.out.println("Hello World!"); 
} 
} 
6
How do I get class files? 
• By compiling all Java files 
$ cd /location/of/java/files 
$ javac Foo.java 
$ ls 
Foo.class Foo.java 
$ 
7
How do I run it? 
• With the java command 
$ java Foo 
Hello World! 
$ 
• Yes you DON’T put the .class extension when you run a class ! 
8
Java Archive 
• aka JAR 
• A collection of compiled Java classes 
• Package of a Java program 
• Can be runnable 
java -jar Foo.jar 
9
That's 
freaking 
AWESOME !
That’s awesome dude. But how 
does all of this work? 
You “ 
11
12 
How does all of this work? 
It is not the beauty of a building you should look at; it's the construction 
of the foundation that will stand the test of time. 
David Allan Coe “
The source code 
• Plain text file 
• File extension: .java 
• Rules for naming each file (covered later) 
13
The bytecode 
14 
• Result of compilation 
• Something in between the source code and the machine’s language 
• Interpreted by the Java Virtual Machine
The Java Virtual Machine 
• aka the JVM 
• Kind of a black box 
• Interprets the Java bytecode 
• Is available on major platforms 
• "Compile once, run everywhere" 
15
A little schema 
Source 
code 
Source 
code 
Byte code JVM 
Byte code JVM 
turns on 
turns on 
java 
java 
javac 
javac 
16
Well man, you’re talking about 
JVM, javac, bytecode and cool 
stuff. But how do I set them up? 
You “ 
17
18 
Developer's environment 
When people think about computer science, they imagine people with 
pocket protectors and thick glasses who code all night. 
Marissa Mayer “
Java Development Kit 
• aka JDK 
• Provides tools 
• javac: java compiler 
• javadoc: generates the documentation 
• ... 
• Includes a Java Runtime Environment 
19
Java Runtime Environment 
• aka JRE 
• Provides tools: 
• java: for running Java applications 
• ... 
20
JAVA_HOME 
• An environment variable 
• Points to the JDK installation 
• Required by some tools such as: 
• IDEs 
• build tools (maven, gradle, ...) 
• ... 
• Used to update the PATH variable 
21
JAVA_HOME: example 
# Unix 
export JAVA_HOME="/path/to/jdk" 
export PATH=$JAVA_HOME/bin:$PATH 
REM Windows 
set JAVA_HOME="C:pathtojdk" 
set PATH=%JAVA_HOME%bin;%PATH% 
22
Avoid spaces in the path of your 
JAVA_HOME. 
JAVA_HOME 
23
JAVA_HOME: test the setup 
To test the setup you can execute the following command: 
24 
$ java -version 
java version "1.8.0_11" 
Java(TM) SE Runtime Environment (build 1.8.0_11-b12) 
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
What does JRE stand for? 
• Java Runtime Embeded 
• Java Routine Exclusive 
• Java Runtime Environment 
Start Stop 
25
What is the correct command to 
execute a Java program? 
• java Foo.java 
• java Foo 
• java Foo.class 
Start Stop 
26
1. Set the JAVA_HOME in your 
environment 
2. Verify your setup 
Practice #1 
27
Practice #2 
Given the following code: 
public class Foo { 
public static void main(String[] args) { 
System.out.println("Hello World!"); 
} 
} 
28
1. Copy it in your favorite editor 
2. Save the file as Foo.java 
3. Compile it 
4. Run it 
Practice #2 
29
30
31 
Appendix
Appendix 
• Java Code conventions 
• Not maintained since 1997, may not be accurate 
32

Más contenido relacionado

La actualidad más candente

JavaScript unit testing with Jasmine
JavaScript unit testing with JasmineJavaScript unit testing with Jasmine
JavaScript unit testing with Jasmine
Yuval Dagai
 

La actualidad más candente (13)

Maven
Maven Maven
Maven
 
DevNexus 2019: Migrating to Java 11
DevNexus 2019: Migrating to Java 11DevNexus 2019: Migrating to Java 11
DevNexus 2019: Migrating to Java 11
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC Mobile
 
Omfw 2013
Omfw 2013Omfw 2013
Omfw 2013
 
JavaScript unit testing with Jasmine
JavaScript unit testing with JasmineJavaScript unit testing with Jasmine
JavaScript unit testing with Jasmine
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Building and Managing Projects with Maven
Building and Managing Projects with MavenBuilding and Managing Projects with Maven
Building and Managing Projects with Maven
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
 
Designing a play framework application
Designing a play framework applicationDesigning a play framework application
Designing a play framework application
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
 

Similar a Java goes wild, lesson 1

Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
attiqrocket
 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basics
tosine
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 

Similar a Java goes wild, lesson 1 (20)

Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java programPj01 2-install java and write first java program
Pj01 2-install java and write first java program
 
OOP Lecture 1-Intro to Java.pptx
OOP Lecture 1-Intro to Java.pptxOOP Lecture 1-Intro to Java.pptx
OOP Lecture 1-Intro to Java.pptx
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
java swing
java swingjava swing
java swing
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
1.Intro--Why Java.pptx
1.Intro--Why Java.pptx1.Intro--Why Java.pptx
1.Intro--Why Java.pptx
 
Java part 1
Java part 1Java part 1
Java part 1
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
The Evolution of Java
The Evolution of JavaThe Evolution of Java
The Evolution of Java
 
How to implement a simple dalvik virtual machine
How to implement a simple dalvik virtual machineHow to implement a simple dalvik virtual machine
How to implement a simple dalvik virtual machine
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
JavaFX - Sketch Board to Production
JavaFX - Sketch Board to ProductionJavaFX - Sketch Board to Production
JavaFX - Sketch Board to Production
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with java
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptxJAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basics
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 

Más de Thierry Wasylczenko

Más de Thierry Wasylczenko (8)

Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9
 
JavaFX et le JDK9
JavaFX et le JDK9JavaFX et le JDK9
JavaFX et le JDK9
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
#JavaFX.forReal()
#JavaFX.forReal()#JavaFX.forReal()
#JavaFX.forReal()
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une application#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une application
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Introduction to JavaFX 2
Introduction to JavaFX 2Introduction to JavaFX 2
Introduction to JavaFX 2
 

Último

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Último (20)

NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 

Java goes wild, lesson 1

  • 1. Java goes wild Lesson 1: Introduction to Java Thierry Wasylczenko
  • 2. After this course ... You will: • Know what is the JDK/JRE • Be able to set up your development environment • Know how to compile and run a Java program 2
  • 3. Agenda • Bascis • How does all of this work? • Developer’s environment 3
  • 4. Basics Success is neither magical nor mysterious. Success is the natural consequence of consistently applying the basic fundamentals. Jim Rohn “ 4
  • 5. Basics • Source code is inside files with .java extension • The source code is compiled into .class files • The class files are executed by a strange thing (covered later) 5
  • 6. A Java file public class Foo { public static void main(String[] args) { System.out.println("Hello World!"); } } 6
  • 7. How do I get class files? • By compiling all Java files $ cd /location/of/java/files $ javac Foo.java $ ls Foo.class Foo.java $ 7
  • 8. How do I run it? • With the java command $ java Foo Hello World! $ • Yes you DON’T put the .class extension when you run a class ! 8
  • 9. Java Archive • aka JAR • A collection of compiled Java classes • Package of a Java program • Can be runnable java -jar Foo.jar 9
  • 11. That’s awesome dude. But how does all of this work? You “ 11
  • 12. 12 How does all of this work? It is not the beauty of a building you should look at; it's the construction of the foundation that will stand the test of time. David Allan Coe “
  • 13. The source code • Plain text file • File extension: .java • Rules for naming each file (covered later) 13
  • 14. The bytecode 14 • Result of compilation • Something in between the source code and the machine’s language • Interpreted by the Java Virtual Machine
  • 15. The Java Virtual Machine • aka the JVM • Kind of a black box • Interprets the Java bytecode • Is available on major platforms • "Compile once, run everywhere" 15
  • 16. A little schema Source code Source code Byte code JVM Byte code JVM turns on turns on java java javac javac 16
  • 17. Well man, you’re talking about JVM, javac, bytecode and cool stuff. But how do I set them up? You “ 17
  • 18. 18 Developer's environment When people think about computer science, they imagine people with pocket protectors and thick glasses who code all night. Marissa Mayer “
  • 19. Java Development Kit • aka JDK • Provides tools • javac: java compiler • javadoc: generates the documentation • ... • Includes a Java Runtime Environment 19
  • 20. Java Runtime Environment • aka JRE • Provides tools: • java: for running Java applications • ... 20
  • 21. JAVA_HOME • An environment variable • Points to the JDK installation • Required by some tools such as: • IDEs • build tools (maven, gradle, ...) • ... • Used to update the PATH variable 21
  • 22. JAVA_HOME: example # Unix export JAVA_HOME="/path/to/jdk" export PATH=$JAVA_HOME/bin:$PATH REM Windows set JAVA_HOME="C:pathtojdk" set PATH=%JAVA_HOME%bin;%PATH% 22
  • 23. Avoid spaces in the path of your JAVA_HOME. JAVA_HOME 23
  • 24. JAVA_HOME: test the setup To test the setup you can execute the following command: 24 $ java -version java version "1.8.0_11" Java(TM) SE Runtime Environment (build 1.8.0_11-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
  • 25. What does JRE stand for? • Java Runtime Embeded • Java Routine Exclusive • Java Runtime Environment Start Stop 25
  • 26. What is the correct command to execute a Java program? • java Foo.java • java Foo • java Foo.class Start Stop 26
  • 27. 1. Set the JAVA_HOME in your environment 2. Verify your setup Practice #1 27
  • 28. Practice #2 Given the following code: public class Foo { public static void main(String[] args) { System.out.println("Hello World!"); } } 28
  • 29. 1. Copy it in your favorite editor 2. Save the file as Foo.java 3. Compile it 4. Run it Practice #2 29
  • 30. 30
  • 32. Appendix • Java Code conventions • Not maintained since 1997, may not be accurate 32