SlideShare a Scribd company logo
Introduction to Java Programming
R.Saravanakumar., MCA
Developer, Trainer, Consultant
Introduction
• JAVA was developed by Sun Microsystems Inc in 1991, later
acquired by Oracle Corporation.
• It was conceived by James Gosling and Patrick Naughton. It is
a simple programming language.
• Writing, compiling and debugging a program is easy in java. It
helps to create modular programs and reusable code.
Features of JAVA
• Java is a platform independent language
• Java is an Object Oriented language
– Object oriented programming is a way of organizing programs as
collection of objects, each of which represents an instance of a class.
– 4 main concepts of Object Oriented programming are:
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Features of JAVA
• Simple
• Robust Language
• Secure
• Java is distributed
• Java is distributed
• Multithreading
• Portable
Compilation and Execution of Java Program
• To create a java code an editor such as
notepad, text pad or an IDE like eclipse can be
used.
• In the above program the class FirstJavaProgram
has public access and hence declared public.
• ‘class’ is the keyword used to create a class.
• For running stand-alone programs ‘main’ method
is needed which has a signature similar to the
one defined in the above program.
• ‘Main’ method takes an array of strings as an
argument. The name of the array can be
anything.
• To display the output, pass the string as an
argument to the method System.out.println.
Steps for compilation and Execution
• Step1: Save the source file as WelcomeApp.java.
• Step2: Open command prompt and navigate to
the directory where you have stored the file.
• Step 3: To compile, type javac
FirstJavaProgram.java and press Enter.
• Step 4: On successful compilation, you will see the command
prompt and FirstJavaProgram.class file in the same folder where
WelcomeApp.java is stored. This is the byte code of the program.
• Step 5: To execute, type java FirstJavaProgram. Do not type the
extension while executing.
• Step 6: See the output “This is my first program in java” displayed
on the console.
Common programming Errors in Java
• ‘javac’ is not recognized as an internal or external
command, operable program or batch file
• Exception in thread
“main”java.lang.NoClassDefFoundError:
FirstJavaProgram
Another Example
Interpreting the code
a) Line 1. The package FirstCode creates a folder to store the class
files generated after compilation
b) Line2. It imports the class library java.lang and its subsequent
classes
c) Line 3. Initiates a class with the name WelcomeMessage
d) Line 5. Declares a method with name printMessage
Interpreting the code
e) Line 7. Defines the actual working code of the method
f) Line 10. Initiates the class having the main method; it should bear the name of the file :
Myclass.java
g) Line 12. Declares the main method
h) Line 14. Initiates the creation of the object
i) Line 15. Calls the method printMessage () with the help of the object
j) The above code is saved and compiled to run on JVM
The programming structure
1) The programming pattern is divided into classes which has meth0d definitions
2) This assists in distributing the code into smaller units
3) The libraries can be used over and over again
4) These codes generated here can be called in another program if required
5) The memory allocation is done only after the execution of the new keyword
6) It gets easier to collect memory that does not has any future use
Java Tutorial – JVM (Java virtual Machine)
1) Class loader accepts class files
2) Compilation creates class files
3) The interim memory is required during execution
4) It consists of heaps, stacks and registers to store data
5) JRE has native methods and libraries
6) JVM runs two main threads
a) demon
b) Non-demon threads
Demon Threads
• It has been Run by JVM for itself. Used for
garbage collection. JVM decides on a thread
for being a demon thread
Non-demon threads
• main() is the initial and non-demon thread.
Other implemented threads are also non-
demon threads. The JVM is active till any non-
demon thread is active.
Execution on JVM
• 1) JVM executes Java byte codes
2) Other programming language codes if converted to adequate Java byte
code can be executed on JVM
3) JVM is different for different platforms and can also act as a platform
itself
4) JVM supports automatic error handling by intercepting the errors
which can be controlled
5) This feature is useful in platform independency and multi user ability of
Java.
Compilation
• 1) The compiler requires to know the TYPE of every CLASS used in
the program source code
2) This is done by setting a default user environment variable
CLASSPATH
3) The Javac (Java Compiler) reads the program and converts it into
byte code files called as class files
Introduction to Java Programming
Java Source code
• 1) It essentially consists of a main() method
2) This method is public and thus can be called by any object
3) This method is also static and so can be called without instantiating the object
of the class
4) It does not return any value
5) The controlling class of every Java application usually contain a main method
6) This can be avoided to allow the class to be tested in a stand-alone mode.
7) Other methods can subsequently be called in main()
End
Ad

More Related Content

What's hot (20)

Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
shamnasain
 
Java
JavaJava
Java
s4al_com
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
Mindfire Solutions
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
Sohanur63
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
RubaNagarajan
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
JVM
JVMJVM
JVM
Prity Bhudolia
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Java Docs
Java DocsJava Docs
Java Docs
Pallavi Srivastava
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Jpa
JpaJpa
Jpa
Manav Prasad
 
Waterfall model ppt final
Waterfall model ppt  finalWaterfall model ppt  final
Waterfall model ppt final
shiva krishna
 
Software Testing Life Cycle – A Beginner’s Guide
Software Testing Life Cycle – A Beginner’s GuideSoftware Testing Life Cycle – A Beginner’s Guide
Software Testing Life Cycle – A Beginner’s Guide
Syed Hassan Raza
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
koolkampus
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual Testing
Hiral Gosani
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
shamnasain
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
Mindfire Solutions
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
Sohanur63
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
RubaNagarajan
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Waterfall model ppt final
Waterfall model ppt  finalWaterfall model ppt  final
Waterfall model ppt final
shiva krishna
 
Software Testing Life Cycle – A Beginner’s Guide
Software Testing Life Cycle – A Beginner’s GuideSoftware Testing Life Cycle – A Beginner’s Guide
Software Testing Life Cycle – A Beginner’s Guide
Syed Hassan Raza
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
koolkampus
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual Testing
Hiral Gosani
 

Similar to Introduction to Java Programming (20)

OOP with Java
OOP with JavaOOP with Java
OOP with Java
OmegaHub
 
Java introduction
Java introductionJava introduction
Java introduction
logeswarisaravanan
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
JAVA PROGRAMING NOTE FOR BEGINNERS 20242JAVA PROGRAMING NOTE FOR BEGINNERS 20242
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
boatengsolo963
 
Java
JavaJava
Java
kavirishi
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
Java
JavaJava
Java
Zeeshan Khan
 
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
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Java introduction
Java introductionJava introduction
Java introduction
Kuppusamy P
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
AdiseshaK
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
sureshkumara29
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
DhanalakshmiVelusamy1
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
Satyam Pandey
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
SmitaBorkar9
 
Java
JavaJava
Java
Sneha Mudraje
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
Umesh Kumar
 
Ad

Recently uploaded (20)

Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Ad

Introduction to Java Programming

  • 1. Introduction to Java Programming R.Saravanakumar., MCA Developer, Trainer, Consultant
  • 2. Introduction • JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. • It was conceived by James Gosling and Patrick Naughton. It is a simple programming language. • Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code.
  • 3. Features of JAVA • Java is a platform independent language • Java is an Object Oriented language – Object oriented programming is a way of organizing programs as collection of objects, each of which represents an instance of a class. – 4 main concepts of Object Oriented programming are: • Abstraction • Encapsulation • Inheritance • Polymorphism
  • 4. Features of JAVA • Simple • Robust Language • Secure • Java is distributed • Java is distributed • Multithreading • Portable
  • 5. Compilation and Execution of Java Program • To create a java code an editor such as notepad, text pad or an IDE like eclipse can be used.
  • 6. • In the above program the class FirstJavaProgram has public access and hence declared public. • ‘class’ is the keyword used to create a class. • For running stand-alone programs ‘main’ method is needed which has a signature similar to the one defined in the above program.
  • 7. • ‘Main’ method takes an array of strings as an argument. The name of the array can be anything. • To display the output, pass the string as an argument to the method System.out.println.
  • 8. Steps for compilation and Execution • Step1: Save the source file as WelcomeApp.java. • Step2: Open command prompt and navigate to the directory where you have stored the file. • Step 3: To compile, type javac FirstJavaProgram.java and press Enter.
  • 9. • Step 4: On successful compilation, you will see the command prompt and FirstJavaProgram.class file in the same folder where WelcomeApp.java is stored. This is the byte code of the program. • Step 5: To execute, type java FirstJavaProgram. Do not type the extension while executing. • Step 6: See the output “This is my first program in java” displayed on the console.
  • 10. Common programming Errors in Java • ‘javac’ is not recognized as an internal or external command, operable program or batch file • Exception in thread “main”java.lang.NoClassDefFoundError: FirstJavaProgram
  • 12. Interpreting the code a) Line 1. The package FirstCode creates a folder to store the class files generated after compilation b) Line2. It imports the class library java.lang and its subsequent classes c) Line 3. Initiates a class with the name WelcomeMessage d) Line 5. Declares a method with name printMessage
  • 13. Interpreting the code e) Line 7. Defines the actual working code of the method f) Line 10. Initiates the class having the main method; it should bear the name of the file : Myclass.java g) Line 12. Declares the main method h) Line 14. Initiates the creation of the object i) Line 15. Calls the method printMessage () with the help of the object j) The above code is saved and compiled to run on JVM
  • 14. The programming structure 1) The programming pattern is divided into classes which has meth0d definitions 2) This assists in distributing the code into smaller units 3) The libraries can be used over and over again 4) These codes generated here can be called in another program if required 5) The memory allocation is done only after the execution of the new keyword 6) It gets easier to collect memory that does not has any future use
  • 15. Java Tutorial – JVM (Java virtual Machine)
  • 16. 1) Class loader accepts class files 2) Compilation creates class files 3) The interim memory is required during execution 4) It consists of heaps, stacks and registers to store data 5) JRE has native methods and libraries 6) JVM runs two main threads a) demon b) Non-demon threads
  • 17. Demon Threads • It has been Run by JVM for itself. Used for garbage collection. JVM decides on a thread for being a demon thread
  • 18. Non-demon threads • main() is the initial and non-demon thread. Other implemented threads are also non- demon threads. The JVM is active till any non- demon thread is active.
  • 19. Execution on JVM • 1) JVM executes Java byte codes 2) Other programming language codes if converted to adequate Java byte code can be executed on JVM 3) JVM is different for different platforms and can also act as a platform itself 4) JVM supports automatic error handling by intercepting the errors which can be controlled 5) This feature is useful in platform independency and multi user ability of Java.
  • 20. Compilation • 1) The compiler requires to know the TYPE of every CLASS used in the program source code 2) This is done by setting a default user environment variable CLASSPATH 3) The Javac (Java Compiler) reads the program and converts it into byte code files called as class files
  • 22. Java Source code • 1) It essentially consists of a main() method 2) This method is public and thus can be called by any object 3) This method is also static and so can be called without instantiating the object of the class 4) It does not return any value 5) The controlling class of every Java application usually contain a main method 6) This can be avoided to allow the class to be tested in a stand-alone mode. 7) Other methods can subsequently be called in main()
  • 23. End
  翻译: