SlideShare a Scribd company logo
Introduction to Java
The Java Platform,
The Java Language, JDK, Eclipse
Svetlin Nakov
Technical Trainer
www.nakov.com
Software University
http://softuni.bg
Table of Contents
1. Your First Java Program
2. The Java Language
3. The Java Platform and JVM
4. JDK – Java SE Development Kit
 Using javac and java
from the command line
5. Java IDEs
6. Java Documentation
2
3
 The "Java Basics" course is NOT for absolute beginners
 Take the "C# Basics" course at SoftUni first:
https://softuni.bg/courses/csharp-basics
 The course is for beginners, but with previous coding skills
 Requirements
 Coding skills – entry level
 Computer English – entry level
 Logical thinking
Warning: Not for Absolute Beginners
Your First Java Program
Writing and Running Java Code in Eclipse
A sample Java program:
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello Java!");
}
}
First Look at Java
5
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello Java!");
}
}
Java Code – How It Works?
6
Define a class
"HelloJava"
Define the main(…) method
– the program entry point
Print a text on the console by calling the
method "println" of the class "System"
7
Formatting Java Code
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello Java!");
}
}
The block after the { symbol
is indented right by a TAB.
The } symbol stays under
the block holding the {.
Class names in Java
are in PascalCase.
The { symbol stays
at the same line.
Method names in Java
are in camelCase.
File Names Should Match Class Names!
 In Java all public classes should stay in a file with the same name
 For example, the class HelloJava should be in the file
HelloJava.java
HelloJava.java
public class HelloJava {
public static void main(String args[]) {
System.out.println("Hello Java!");
}
}
Your First Java Program
Live Demo
10
 Java is very popular programming language
 A syntax to describe computer programs
 Object-oriented, statically typed, similar to C#
 Easy to learn, easy to read, easy to understand
 Java is a development platform
 Java SE, Java EE, JavaFX, Java ME, Android
 Runs compiled Java code in a virtual machine (JVM)
 Runs on millions of devices, in any OS
What is "Java"?
The Java Programming Language
12
 Java programming language
 High-level object-oriented general purpose language
 Statically typed (not dynamic like JavaScript)
 Type-safe (runs in a virtual machine, called JVM)
 Easy to learn, easy to read, easy to understand
 Good for large server-side projects
 Similar to C# and C++, but less capable
 Highly portable (write once, run everywhere)
The Java Programming Language
The Java Platform
Java, JVM, JDK
14
 Environment for execution of Java code
 JVM (Java Virtual Machine)
 Java programming language
 Powerful class library (Java API) and programing model
 Ability to run Java programs on any machine with JVM
 Windows, Linux, MacOS, Android, your TV, your car, ...
 Java Platform Editions
 Java SE, Java EE, Android, Java ME, Java Card, Java Embedded, …
The Java Platform
15
 Java 1.0a2 (1995) – started as platform for Java applets
 JDK 1.0 (1996) – Java language, JDK, JVM, standard API classes
 JDK 1.1 (1997) – AWT UI framework, JavaBeans, JDBC
 J2SE 1.2 (1998) – J2SE, J2EE, J2ME, Swing UI framework, collections
 J2SE 1.3 (2000) – HotSpot JVM, JavaSound, JNDI
 J2SE 1.4 (2002) – Java Web Start, JAXP, regular expressions
 J2SE 5.0 (2004) – generics, varargs, foreach, autoboxing, enums
 Java SE 6 (2006) – GUI improvements, JVM improvements, open-source
 Oracle buys Sun (2009) – Java becomes more open
 Java SE 7 (2011) – dynamic languages, new I/O, try-with-resources
 Java SE 8 (2014) – lambda expressions, streams API, JavaFX UI framework
The Java Platform – History
16
 JVM – Java Virtual Machine
 Executes compiled Java bytecode (compiled programs)
 Virtual environment for safe code execution
 Similar to CLR in .NET
 JRE – Java Runtime Environment
 A runtime environment for Java-based software
 Similar to .NET Framework
 JRE = JVM + Java API classes (standard Java libraries)
 Available for Windows, Linux, Mac OS X (no Android and iOS version)
Java Platform: Terminology
17
 JDK – Java Development Kit (Java SDK)
 The development platform for Java developers
 Consists of JRE (JVM + API classes) + compilers + tools
 Available for several OS: Windows, Linux, Mac OS X
 Note that Android SDK is not type of JDK (it is separate platform)
 Class file (.class file)
 A compiled Java code (or Python / Groovy / other language code)
 Holds Java bytecode + metadata
 Usually multiple class files are packed into a JAR archive
Java Platform: Terminology (2)
18
 JAR archive (.jar files)
 JAR archives hold a set of classes and resources
 Like the assemblies in .NET Framework (.dll files)
 JAR files are ZIP archives with files + manifest (metadata XML)
 Classpath
 A set of directories and JAR archives holding your application's
classes and resources (e.g. images, icons, sounds, etc.)
 When loading a class or resource, the JVM traverses the classpath
to find the requested classes or files
Java Platform: Terminology (2)
Java Compilation and Execution
public class HelloJava {
public static void
main(String args[]) {
System.out.println(
"Hello Java!");
}
}
(source code)
Compilation (javac) CAFE BABE 6D61 696E 0100 1628 5B4C
6A61 7661 2F6C 616E 672F 5374 7269
6E67 3B29 5609 0011 0013 0700 1201
0010 6A61 7661 2F6C 616E 672F 5379
7374 656D 0C00 1400 1501 0003 6F75
7401 0015 4C6A 6176 612F 696F 2F50
7269 6E74 5374 7265 616D 3B08 0017
0100 0C48 656C 6C6F 2C20 4A61
(bytecode)Execution (java)
JVM
HelloJava.java HelloJava.class
20
Cross-Platform Java
 Cross-platform
compilation and execution
 Java / Python code 
.class / .jar files 
execution in the JVM
 JVM runs on many devices
 Bytecode is portable by
nature
Console-Based Compilation
and Execution of Java Code
Live Demo (in Linux and Windows)
21
22
 Java SE (Java Standard Edition)
 For standalone Java applications and Java applets
 Java EE (Java Enterprise Edition)
 For server-side, enterprise, Web applications and Web services
 A set of APIs and server specifications built on top of Java SE
 Java ME (Java Micro Edition)
 A pared down version of Java SE and API’s for embedded devices
 Android
 Android is Java-like platform for Android tablets and smartphones
Java Platform Editions
23
Java SE 8 Platform
* Learn more at http://docs.oracle.com/javase/8/docs/index.html
24
 In Java the classes usually stay in packages (like namespaces in C#)
 A package holds a set of classes and other (inner) packages
 Packages are included by "import package.subpackage.*"
 Project directory structure always follows the package structure
Packages in Java
src/org/softuni/main/Main.java
package org.softuni.main;
import org.softuni.data;
public class Main { … }
src/org/softuni/data/Student.java
package org.softuni.data;
public class Student { … }
25
 A JAR file holds a set of classes
and resources
 Folders follow the package
structure of the classes
 JAR files are ZIP archives
 Created by Eclipse or by a
console tool called "jar"
Creating a JAR File
jar -cf archive.jar <files>
Creating a JAR File and
Configuring the Classpath
Live Demo
27
 A programming language
 Java, C#, PHP, Python, …
 Task to solve: project description
 Development platform: IDE, compilers, SDK
 IDE (Eclipse, NetBeans, Visual Studio), Java SDK, Android SDK
 Set of standard classes (class library)
 Java API classes / .NET API classes / PHP standard functions
 Help documentation
 Java API documentation / .NET API documentation
What You Need to Program?
Java IDEs
Eclipse, NetBeans, IntelliJ IDEA
29
 Eclipse is popular IDE (Integrated Development Environment)
 For many languages: Java, PHP, Python, JavaScript, HTML, CSS, …
 Eclipse is IDE that helps us to:
 Write code
 Design user interface
 Compile code
 Execute / test / debug code
 Browse the help
 Manage project's files
Eclipse – IDE for Java Developers
30
 Eclipse is a single tool for:
 Writing code in many languages (Java, PHP, C++, JavaScript…)
 Using different technologies (Web, mobile, embedded, …)
 Complete integration of most development activities
 Coding, compiling, running, testing, debugging, UI design,
deployment, version control, ...
 Free and open-source – www.eclipse.org
 Easy to use and intuitive
Benefits of Eclipse
Eclipse IDE
Creating, Compiling, Running and
Debugging Java Programs – Live Demo
 NetBeans is an open-source IDE for Java developers
 Supports Java, C++, PHP, HTML5
 Developed by Oracle (formerly by Sun Microsystems)
 Written in Java, runs on Windows, Linux, Mac OS X
 Supports the latest Java SE and Java EE technologies
 Integrated features: code editor, debugger,
profiler, GUI editor, source control tools, etc.
 www.netbeans.org
NetBeans
NetBeans
Live Demo
 IntelliJ IDEA is а powerful IDE for Java developers
 Very good usability, helps you a lot with writing code
 Supports Java, PHP, Python, Ruby, HTML5, SQL
 The free edition support only Java and basic features
 Advanced features, PHP, Python, Ruby, SQL, Java EE,
Android, etc. are commercial
 Written in Java, runs on Windows, Linux, Mac OS X
 http://www.jetbrains.com/idea/
IntelliJ IDEA
IntelliJ IDEA
Live Demo
Java Documentation
37
 Java 8 API Documentation
 http://docs.oracle.com/javase/8/docs/api/
 Complete documentation of all classes and their functionality
 With descriptions of all methods, properties, events, etc.
 Java 8 official documentation:
 http://docs.oracle.com/javase/8/docs/
 The Java Tutorial
 http://docs.oracle.com/javase/tutorial/
Java Documentation
Java API Documentation
Live Demo
39
 The Java platform consists of
 The Java language
 Java Virtual Machine
 Java API classes
 One Java platform, several editions
 Java SE, Java EE, Java ME, Android
 JDK = JRE + compilers and tools
 Eclipse – powerful open-source Java IDE
Summary
?
https://softuni.bg/courses/java-basics/
Introduction to Java
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
 Attribution: this work may contain portions from
 "Fundamentals of Computer Programming with Java" book by Svetlin Nakov & Co. under CC-BY-SA license
 "C# Basics" course by Software University under CC-BY-NC-SA license
41
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.bg
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University @ YouTube
 youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg

More Related Content

What's hot (20)

PPTX
Java programming course for beginners
Eduonix Learning Solutions
 
PPTX
Chapter 2.1
sotlsoc
 
PPT
Unit 2 Java
arnold 7490
 
DOCX
Introduction to java
jayc8586
 
PPTX
Chapter 1
siragezeynu
 
PPT
Chapter 1 introduction to java technology
sshhzap
 
PPTX
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
PDF
An Introduction to Java Compiler and Runtime
Omar Bashir
 
PDF
Introduction to java technology
Indika Munaweera Kankanamge
 
PPTX
1 java programming- introduction
jyoti_lakhani
 
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
PDF
109842496 jni
Vishal Singh
 
PPT
Java basic introduction
Ideal Eyes Business College
 
PPTX
Core java over view basics introduction by quontra solutions
QUONTRASOLUTIONS
 
PPTX
Introduction to java
Java Lover
 
PPT
Fundamentals of JAVA
KUNAL GADHIA
 
PPTX
Java byte code & virtual machine
Laxman Puri
 
PPTX
Basics of JAVA programming
Elizabeth Thomas
 
PDF
Java notes
Manish Swarnkar
 
PPTX
1.introduction to java
Madhura Bhalerao
 
Java programming course for beginners
Eduonix Learning Solutions
 
Chapter 2.1
sotlsoc
 
Unit 2 Java
arnold 7490
 
Introduction to java
jayc8586
 
Chapter 1
siragezeynu
 
Chapter 1 introduction to java technology
sshhzap
 
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Introduction to java technology
Indika Munaweera Kankanamge
 
1 java programming- introduction
jyoti_lakhani
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
109842496 jni
Vishal Singh
 
Java basic introduction
Ideal Eyes Business College
 
Core java over view basics introduction by quontra solutions
QUONTRASOLUTIONS
 
Introduction to java
Java Lover
 
Fundamentals of JAVA
KUNAL GADHIA
 
Java byte code & virtual machine
Laxman Puri
 
Basics of JAVA programming
Elizabeth Thomas
 
Java notes
Manish Swarnkar
 
1.introduction to java
Madhura Bhalerao
 

Similar to 01. Introduction to programming with java (20)

PDF
Java - At a glance
Nitish Baranwal
 
PPSX
Intoduction to java
jalinder123
 
PPSX
Dr. Rajeshree Khande :Intoduction to java
DrRajeshreeKhande
 
PPTX
1_Introduction to Java.pptx java programming
amitraj53904
 
PDF
Java ppt1
nikhilsh66131
 
PDF
Learn Java Part 1
Gurpreet singh
 
PPTX
Java Lecture 1
Qualys
 
PPTX
Presentation on Java Basic
Rustamji Institute of Technology
 
PPTX
java basics.pptx
mlakshumaiah
 
PPT
Javalecture 1
mrinalbhutani
 
PDF
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
PPTX
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
PPTX
Java Course In Thane,Mumbai
nettech90
 
PPTX
1 introduction
Mks Khalid
 
PPT
Introduction to java programming part 1
university of education,Lahore
 
PPTX
Netbeans
acosdt
 
PPTX
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
PDF
What is-java
Shahid Rasheed
 
PPT
Java platform
BG Java EE Course
 
PPTX
Java -lec-1
Zubair Khalid
 
Java - At a glance
Nitish Baranwal
 
Intoduction to java
jalinder123
 
Dr. Rajeshree Khande :Intoduction to java
DrRajeshreeKhande
 
1_Introduction to Java.pptx java programming
amitraj53904
 
Java ppt1
nikhilsh66131
 
Learn Java Part 1
Gurpreet singh
 
Java Lecture 1
Qualys
 
Presentation on Java Basic
Rustamji Institute of Technology
 
java basics.pptx
mlakshumaiah
 
Javalecture 1
mrinalbhutani
 
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Java Course In Thane,Mumbai
nettech90
 
1 introduction
Mks Khalid
 
Introduction to java programming part 1
university of education,Lahore
 
Netbeans
acosdt
 
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
What is-java
Shahid Rasheed
 
Java platform
BG Java EE Course
 
Java -lec-1
Zubair Khalid
 
Ad

More from Intro C# Book (20)

PPTX
17. Java data structures trees representation and traversal
Intro C# Book
 
PPTX
Java Problem solving
Intro C# Book
 
PPTX
20.5 Java polymorphism
Intro C# Book
 
PPTX
20.4 Java interfaces and abstraction
Intro C# Book
 
PPTX
20.3 Java encapsulation
Intro C# Book
 
PPTX
20.2 Java inheritance
Intro C# Book
 
PPTX
20.1 Java working with abstraction
Intro C# Book
 
PPTX
19. Java data structures algorithms and complexity
Intro C# Book
 
PPTX
18. Java associative arrays
Intro C# Book
 
PPTX
16. Java stacks and queues
Intro C# Book
 
PPTX
14. Java defining classes
Intro C# Book
 
PPTX
13. Java text processing
Intro C# Book
 
PPTX
12. Java Exceptions and error handling
Intro C# Book
 
PPTX
11. Java Objects and classes
Intro C# Book
 
PPTX
09. Java Methods
Intro C# Book
 
PPTX
05. Java Loops Methods and Classes
Intro C# Book
 
PPTX
07. Java Array, Set and Maps
Intro C# Book
 
PPTX
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
PPTX
02. Data Types and variables
Intro C# Book
 
PPTX
23. Methodology of Problem Solving
Intro C# Book
 
17. Java data structures trees representation and traversal
Intro C# Book
 
Java Problem solving
Intro C# Book
 
20.5 Java polymorphism
Intro C# Book
 
20.4 Java interfaces and abstraction
Intro C# Book
 
20.3 Java encapsulation
Intro C# Book
 
20.2 Java inheritance
Intro C# Book
 
20.1 Java working with abstraction
Intro C# Book
 
19. Java data structures algorithms and complexity
Intro C# Book
 
18. Java associative arrays
Intro C# Book
 
16. Java stacks and queues
Intro C# Book
 
14. Java defining classes
Intro C# Book
 
13. Java text processing
Intro C# Book
 
12. Java Exceptions and error handling
Intro C# Book
 
11. Java Objects and classes
Intro C# Book
 
09. Java Methods
Intro C# Book
 
05. Java Loops Methods and Classes
Intro C# Book
 
07. Java Array, Set and Maps
Intro C# Book
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
02. Data Types and variables
Intro C# Book
 
23. Methodology of Problem Solving
Intro C# Book
 
Ad

Recently uploaded (20)

PDF
BRKACI-1003 ACI Brownfield Migration - Real World Experiences and Best Practi...
fcesargonca
 
PDF
Cleaning up your RPKI invalids, presented at PacNOG 35
APNIC
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PDF
BRKACI-1001 - Your First 7 Days of ACI.pdf
fcesargonca
 
PPTX
Orchestrating things in Angular application
Peter Abraham
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
DOCX
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PPTX
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PPTX
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
PPTX
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
PPTX
internet básico presentacion es una red global
70965857
 
PDF
The Internet - By the numbers, presented at npNOG 11
APNIC
 
PPT
introduction to networking with basics coverage
RamananMuthukrishnan
 
PPTX
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
PPTX
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
BRKACI-1003 ACI Brownfield Migration - Real World Experiences and Best Practi...
fcesargonca
 
Cleaning up your RPKI invalids, presented at PacNOG 35
APNIC
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
BRKACI-1001 - Your First 7 Days of ACI.pdf
fcesargonca
 
Orchestrating things in Angular application
Peter Abraham
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
internet básico presentacion es una red global
70965857
 
The Internet - By the numbers, presented at npNOG 11
APNIC
 
introduction to networking with basics coverage
RamananMuthukrishnan
 
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 

01. Introduction to programming with java

  • 1. Introduction to Java The Java Platform, The Java Language, JDK, Eclipse Svetlin Nakov Technical Trainer www.nakov.com Software University http://softuni.bg
  • 2. Table of Contents 1. Your First Java Program 2. The Java Language 3. The Java Platform and JVM 4. JDK – Java SE Development Kit  Using javac and java from the command line 5. Java IDEs 6. Java Documentation 2
  • 3. 3  The "Java Basics" course is NOT for absolute beginners  Take the "C# Basics" course at SoftUni first: https://softuni.bg/courses/csharp-basics  The course is for beginners, but with previous coding skills  Requirements  Coding skills – entry level  Computer English – entry level  Logical thinking Warning: Not for Absolute Beginners
  • 4. Your First Java Program Writing and Running Java Code in Eclipse
  • 5. A sample Java program: public class HelloJava { public static void main(String[] args) { System.out.println("Hello Java!"); } } First Look at Java 5
  • 6. public class HelloJava { public static void main(String[] args) { System.out.println("Hello Java!"); } } Java Code – How It Works? 6 Define a class "HelloJava" Define the main(…) method – the program entry point Print a text on the console by calling the method "println" of the class "System"
  • 7. 7 Formatting Java Code public class HelloJava { public static void main(String[] args) { System.out.println("Hello Java!"); } } The block after the { symbol is indented right by a TAB. The } symbol stays under the block holding the {. Class names in Java are in PascalCase. The { symbol stays at the same line. Method names in Java are in camelCase.
  • 8. File Names Should Match Class Names!  In Java all public classes should stay in a file with the same name  For example, the class HelloJava should be in the file HelloJava.java HelloJava.java public class HelloJava { public static void main(String args[]) { System.out.println("Hello Java!"); } }
  • 9. Your First Java Program Live Demo
  • 10. 10  Java is very popular programming language  A syntax to describe computer programs  Object-oriented, statically typed, similar to C#  Easy to learn, easy to read, easy to understand  Java is a development platform  Java SE, Java EE, JavaFX, Java ME, Android  Runs compiled Java code in a virtual machine (JVM)  Runs on millions of devices, in any OS What is "Java"?
  • 12. 12  Java programming language  High-level object-oriented general purpose language  Statically typed (not dynamic like JavaScript)  Type-safe (runs in a virtual machine, called JVM)  Easy to learn, easy to read, easy to understand  Good for large server-side projects  Similar to C# and C++, but less capable  Highly portable (write once, run everywhere) The Java Programming Language
  • 14. 14  Environment for execution of Java code  JVM (Java Virtual Machine)  Java programming language  Powerful class library (Java API) and programing model  Ability to run Java programs on any machine with JVM  Windows, Linux, MacOS, Android, your TV, your car, ...  Java Platform Editions  Java SE, Java EE, Android, Java ME, Java Card, Java Embedded, … The Java Platform
  • 15. 15  Java 1.0a2 (1995) – started as platform for Java applets  JDK 1.0 (1996) – Java language, JDK, JVM, standard API classes  JDK 1.1 (1997) – AWT UI framework, JavaBeans, JDBC  J2SE 1.2 (1998) – J2SE, J2EE, J2ME, Swing UI framework, collections  J2SE 1.3 (2000) – HotSpot JVM, JavaSound, JNDI  J2SE 1.4 (2002) – Java Web Start, JAXP, regular expressions  J2SE 5.0 (2004) – generics, varargs, foreach, autoboxing, enums  Java SE 6 (2006) – GUI improvements, JVM improvements, open-source  Oracle buys Sun (2009) – Java becomes more open  Java SE 7 (2011) – dynamic languages, new I/O, try-with-resources  Java SE 8 (2014) – lambda expressions, streams API, JavaFX UI framework The Java Platform – History
  • 16. 16  JVM – Java Virtual Machine  Executes compiled Java bytecode (compiled programs)  Virtual environment for safe code execution  Similar to CLR in .NET  JRE – Java Runtime Environment  A runtime environment for Java-based software  Similar to .NET Framework  JRE = JVM + Java API classes (standard Java libraries)  Available for Windows, Linux, Mac OS X (no Android and iOS version) Java Platform: Terminology
  • 17. 17  JDK – Java Development Kit (Java SDK)  The development platform for Java developers  Consists of JRE (JVM + API classes) + compilers + tools  Available for several OS: Windows, Linux, Mac OS X  Note that Android SDK is not type of JDK (it is separate platform)  Class file (.class file)  A compiled Java code (or Python / Groovy / other language code)  Holds Java bytecode + metadata  Usually multiple class files are packed into a JAR archive Java Platform: Terminology (2)
  • 18. 18  JAR archive (.jar files)  JAR archives hold a set of classes and resources  Like the assemblies in .NET Framework (.dll files)  JAR files are ZIP archives with files + manifest (metadata XML)  Classpath  A set of directories and JAR archives holding your application's classes and resources (e.g. images, icons, sounds, etc.)  When loading a class or resource, the JVM traverses the classpath to find the requested classes or files Java Platform: Terminology (2)
  • 19. Java Compilation and Execution public class HelloJava { public static void main(String args[]) { System.out.println( "Hello Java!"); } } (source code) Compilation (javac) CAFE BABE 6D61 696E 0100 1628 5B4C 6A61 7661 2F6C 616E 672F 5374 7269 6E67 3B29 5609 0011 0013 0700 1201 0010 6A61 7661 2F6C 616E 672F 5379 7374 656D 0C00 1400 1501 0003 6F75 7401 0015 4C6A 6176 612F 696F 2F50 7269 6E74 5374 7265 616D 3B08 0017 0100 0C48 656C 6C6F 2C20 4A61 (bytecode)Execution (java) JVM HelloJava.java HelloJava.class
  • 20. 20 Cross-Platform Java  Cross-platform compilation and execution  Java / Python code  .class / .jar files  execution in the JVM  JVM runs on many devices  Bytecode is portable by nature
  • 21. Console-Based Compilation and Execution of Java Code Live Demo (in Linux and Windows) 21
  • 22. 22  Java SE (Java Standard Edition)  For standalone Java applications and Java applets  Java EE (Java Enterprise Edition)  For server-side, enterprise, Web applications and Web services  A set of APIs and server specifications built on top of Java SE  Java ME (Java Micro Edition)  A pared down version of Java SE and API’s for embedded devices  Android  Android is Java-like platform for Android tablets and smartphones Java Platform Editions
  • 23. 23 Java SE 8 Platform * Learn more at http://docs.oracle.com/javase/8/docs/index.html
  • 24. 24  In Java the classes usually stay in packages (like namespaces in C#)  A package holds a set of classes and other (inner) packages  Packages are included by "import package.subpackage.*"  Project directory structure always follows the package structure Packages in Java src/org/softuni/main/Main.java package org.softuni.main; import org.softuni.data; public class Main { … } src/org/softuni/data/Student.java package org.softuni.data; public class Student { … }
  • 25. 25  A JAR file holds a set of classes and resources  Folders follow the package structure of the classes  JAR files are ZIP archives  Created by Eclipse or by a console tool called "jar" Creating a JAR File jar -cf archive.jar <files>
  • 26. Creating a JAR File and Configuring the Classpath Live Demo
  • 27. 27  A programming language  Java, C#, PHP, Python, …  Task to solve: project description  Development platform: IDE, compilers, SDK  IDE (Eclipse, NetBeans, Visual Studio), Java SDK, Android SDK  Set of standard classes (class library)  Java API classes / .NET API classes / PHP standard functions  Help documentation  Java API documentation / .NET API documentation What You Need to Program?
  • 29. 29  Eclipse is popular IDE (Integrated Development Environment)  For many languages: Java, PHP, Python, JavaScript, HTML, CSS, …  Eclipse is IDE that helps us to:  Write code  Design user interface  Compile code  Execute / test / debug code  Browse the help  Manage project's files Eclipse – IDE for Java Developers
  • 30. 30  Eclipse is a single tool for:  Writing code in many languages (Java, PHP, C++, JavaScript…)  Using different technologies (Web, mobile, embedded, …)  Complete integration of most development activities  Coding, compiling, running, testing, debugging, UI design, deployment, version control, ...  Free and open-source – www.eclipse.org  Easy to use and intuitive Benefits of Eclipse
  • 31. Eclipse IDE Creating, Compiling, Running and Debugging Java Programs – Live Demo
  • 32.  NetBeans is an open-source IDE for Java developers  Supports Java, C++, PHP, HTML5  Developed by Oracle (formerly by Sun Microsystems)  Written in Java, runs on Windows, Linux, Mac OS X  Supports the latest Java SE and Java EE technologies  Integrated features: code editor, debugger, profiler, GUI editor, source control tools, etc.  www.netbeans.org NetBeans
  • 34.  IntelliJ IDEA is а powerful IDE for Java developers  Very good usability, helps you a lot with writing code  Supports Java, PHP, Python, Ruby, HTML5, SQL  The free edition support only Java and basic features  Advanced features, PHP, Python, Ruby, SQL, Java EE, Android, etc. are commercial  Written in Java, runs on Windows, Linux, Mac OS X  http://www.jetbrains.com/idea/ IntelliJ IDEA
  • 37. 37  Java 8 API Documentation  http://docs.oracle.com/javase/8/docs/api/  Complete documentation of all classes and their functionality  With descriptions of all methods, properties, events, etc.  Java 8 official documentation:  http://docs.oracle.com/javase/8/docs/  The Java Tutorial  http://docs.oracle.com/javase/tutorial/ Java Documentation
  • 39. 39  The Java platform consists of  The Java language  Java Virtual Machine  Java API classes  One Java platform, several editions  Java SE, Java EE, Java ME, Android  JDK = JRE + compilers and tools  Eclipse – powerful open-source Java IDE Summary
  • 41. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license  Attribution: this work may contain portions from  "Fundamentals of Computer Programming with Java" book by Svetlin Nakov & Co. under CC-BY-SA license  "C# Basics" course by Software University under CC-BY-NC-SA license 41
  • 42. Free Trainings @ Software University  Software University Foundation – softuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University @ YouTube  youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bg

Editor's Notes

  • #7: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #8: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #11: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #28: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #30: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #31: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  • #38: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*