SlideShare a Scribd company logo
1 of 10
How to run Java Program
without IDE.
How to do it!!
1. Create a folder in eg: D: (D Drive) and name it eg: (myapplication)
2. Create a source file eg: (HelloWorldApp.java) in notepad
save as Text Documents(*.txt) and keep Encoding combo box as ANSI and Save.
Code
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
3. Now you need to compile your file for that you need JRE
4. You need to set path varible i.e environment variable in order to run your program.
5. Open command prompt
cd D:
cd myapplication
set path=C:Program FilesJavajdk1.8.0.60bin;
javac HelloWorldApp.java
java -cp . HelloWorldApp
6. And here your program runs.
How actually it works!!
1. Because of Software based Virtual machine that acts as run time engine to run particular
programming language application. i.e JVM(Java Virtual Machine)
2. JVM is a part of JRE and it is responsible to load and run the java class file.
3. While working with command prompt we need to invoke the Java compiler by supplying javac
command where it comes in contact with JDK(Java Devlopment Kit)
4. JDK is a bundle software needed for developing Java Application. It has (JRE, set of API classes, Java
Compiler, Webstart and additionalfiles needed to write Java Applets and applications)
5. Java directly do not execute Java program- that job is only of JVM(Java Virtual Machine).
6. However, the Java virtual machine cannot execute .java files directly. The compiler's job is to
translate Java source files into "class files" that the virtual machine can execute.
7. Now if you need to compile multiple .java files together, then its possible by just "javac
HelloWorldApp.java one.java two.java" or "javac *.java".
8. And one more thing, Java compiler doesn't create an object file, but instead it creates a bytecode
file which is, essentially, an object file for a virtual machine.
9. However, bytecode is not an executable file.
To execute a bytecode file, you actually need to invoke a Java interpreter (called java).
Every platform has its own Java interpreter which will automatically address the platform-specific
issues that can no longer be put off.
When platform-specific operations are required by the bytecode, the Java interpreter links in
appropriate code specific to the platform.
Loading of Classes and Interfaces
Loading means read .class file from hard disk and store
corresponding binary data inside method area of JVM.
For each .class file JVM will store following information
1. Fully qualified name of class
2. Fully qualified name of immediate parent
3. Whether .class file represents class|interface|enum
4. Methods|Constructors|Variables information
5. Modifiers information
6. Constant Pool information
Linking of Classes and Interfaces
After “loading” activity JVM immediately perform Linking activity. Linking once again contain 3
activities,
1. Verification
in java .class files we never getting these alert messages.
What is the reason is inside JVM a special component is there i.e., Byte Code Verifier.
This Byte Code Verifier is responsible to verify weather .class file is properly formatted or not,
structurally correct or not, generated by valid compiler or not. If the .class file is not generated by
valid compiler then Byte Code Verifier raises runtime error java.lang.VerifyError.
This total process is done in verification activity.
2. Preparation
In preparation phase, JVM will allocate memory for class level static variables and assigned default
values.
E.g. For int ---> 0, For double ---> 0.0, For boolean ---> false
Here just default values will be assigned and original values will be assigned in initialization phase.
3. Resolution
Next phase is Resolution.
It is the process of replacing all symbolic references used in our class with original direct references
from method area.
Run Java Program - Initialization
• In Initialization activity, for class level static variables assigns
original values and static blocks will be executed from top to
bottom.
• While Loading, Linking and Initialization if any error occurs
then we will get runtime Exception saying
java.lang.LinkageError. Previously we discussed about
VerifyError. This is the child class of LinkageError.
Types of class loaders in class loader
subsystem
1. Bootstrap class loader/ Primordial class loader
Bootstrap class loader is responsible for to load classes from bootstrap class path.
Here bootstrap class path means, usually in java application internal JVM uses rt.jar.
All core java API classes like String class, StringBuilder class, StringBuffer class, java.lang packages,
java.io - enthusiast about java & open-source? packages etc are available in rt.jar.
This rt.jar path is known as bootstrap class path and the path of rt.jar is
jdk --> jre --> lib --> rt.jar
This location by default consider as bootstrap class path.
This Bootstrap class loader is responsible for loading all the classes inside this rt.jar.
This Bootstrap class loader is implemented not in java it is implemented by native languages like C,
C++ etc.
2. Extension class loader
The extension class loader is the child of bootstrap class loader. This class loader is responsible to
load classes from extension class path
jdk --> jre --> lib-->ext -->*.jar
The extension class loader is responsible for loading all the classes present in the ext folder.
This Extension class loader is implemented in java only. The class name of extension class loader is
sun.misc.Launcher$ExtClassLoader.class
3. Application class loader/System class loader
The Application class loader is the child of Extension class loader.
This class loader is responsible to load classes from Application class path.
Application class path means classes in our application (Environment variable class path).
It internally uses environment vatiable path. This Application class loader is implemented in java
only.
The class name of extension class loader is
sun.misc.Launcher$AppClassLoader.class
Example
public class LoaderTest {
public static void main(String[] args) {
System.out.println(String.class.getClassLoader());
System.out.println(Employee123.class.getClassLoader());
System.out.println(LoaderTest.class.getClassLoader());
}
}
Output:
null // Because Bootstrap class loader is not java object it is designed with
C or C++
sun.misc.Launcher$ExtClassLoader@33909752 //Here i am created class
Employee123 and create jar for this class and put in ext folder
sun.misc.Launcher$AppClassLoader@73d16e93
Run Java Program - Invoking HelloWorld.main
Thank You!!

More Related Content

What's hot (20)

Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
X3DOM - An Overview and Examples
X3DOM - An Overview and ExamplesX3DOM - An Overview and Examples
X3DOM - An Overview and Examples
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
 
Publish Android Application on Google Play Store
Publish Android Application on Google Play Store Publish Android Application on Google Play Store
Publish Android Application on Google Play Store
 
JVM
JVMJVM
JVM
 
Java seminar
Java seminarJava seminar
Java seminar
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
The Evolution of Java
The Evolution of JavaThe Evolution of Java
The Evolution of Java
 
Asp net
Asp netAsp net
Asp net
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
C# language
C# languageC# language
C# language
 
Swift programming language
Swift programming languageSwift programming language
Swift programming language
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Java notes
Java notesJava notes
Java notes
 
Modular programming in qbasic
Modular programming in qbasicModular programming in qbasic
Modular programming in qbasic
 

Similar to How to run Java programs without an IDE

Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
Unit of competency
Unit of competencyUnit of competency
Unit of competencyloidasacueza
 
College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionGanesh Samarthyam
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)Prof. Erwin Globio
 
Java Interview Questions Answers Guide
Java Interview Questions Answers GuideJava Interview Questions Answers Guide
Java Interview Questions Answers GuideDaisyWatson5
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javajayc8586
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruNithin Kumar,VVCE, Mysuru
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorialjackschitze
 

Similar to How to run Java programs without an IDE (20)

JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 
Core java introduction
Core java introduction Core java introduction
Core java introduction
 
B.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: AppetB.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: Appet
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Java Intro
Java IntroJava Intro
Java Intro
 
Java JDK.docx
Java JDK.docxJava JDK.docx
Java JDK.docx
 
College Project - Java Disassembler - Description
College Project - Java Disassembler - DescriptionCollege Project - Java Disassembler - Description
College Project - Java Disassembler - Description
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java Interview Questions Answers Guide
Java Interview Questions Answers GuideJava Interview Questions Answers Guide
Java Interview Questions Answers Guide
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorial
 
Basic Java I
Basic Java IBasic Java I
Basic Java I
 
Java basic
Java basicJava basic
Java basic
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

How to run Java programs without an IDE

  • 1. How to run Java Program without IDE.
  • 2. How to do it!! 1. Create a folder in eg: D: (D Drive) and name it eg: (myapplication) 2. Create a source file eg: (HelloWorldApp.java) in notepad save as Text Documents(*.txt) and keep Encoding combo box as ANSI and Save. Code /** * The HelloWorldApp class implements an application that * simply prints "Hello World!" to standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. } } 3. Now you need to compile your file for that you need JRE 4. You need to set path varible i.e environment variable in order to run your program. 5. Open command prompt cd D: cd myapplication set path=C:Program FilesJavajdk1.8.0.60bin; javac HelloWorldApp.java java -cp . HelloWorldApp 6. And here your program runs.
  • 3. How actually it works!! 1. Because of Software based Virtual machine that acts as run time engine to run particular programming language application. i.e JVM(Java Virtual Machine) 2. JVM is a part of JRE and it is responsible to load and run the java class file. 3. While working with command prompt we need to invoke the Java compiler by supplying javac command where it comes in contact with JDK(Java Devlopment Kit) 4. JDK is a bundle software needed for developing Java Application. It has (JRE, set of API classes, Java Compiler, Webstart and additionalfiles needed to write Java Applets and applications) 5. Java directly do not execute Java program- that job is only of JVM(Java Virtual Machine). 6. However, the Java virtual machine cannot execute .java files directly. The compiler's job is to translate Java source files into "class files" that the virtual machine can execute. 7. Now if you need to compile multiple .java files together, then its possible by just "javac HelloWorldApp.java one.java two.java" or "javac *.java". 8. And one more thing, Java compiler doesn't create an object file, but instead it creates a bytecode file which is, essentially, an object file for a virtual machine. 9. However, bytecode is not an executable file. To execute a bytecode file, you actually need to invoke a Java interpreter (called java). Every platform has its own Java interpreter which will automatically address the platform-specific issues that can no longer be put off. When platform-specific operations are required by the bytecode, the Java interpreter links in appropriate code specific to the platform.
  • 4. Loading of Classes and Interfaces Loading means read .class file from hard disk and store corresponding binary data inside method area of JVM. For each .class file JVM will store following information 1. Fully qualified name of class 2. Fully qualified name of immediate parent 3. Whether .class file represents class|interface|enum 4. Methods|Constructors|Variables information 5. Modifiers information 6. Constant Pool information
  • 5. Linking of Classes and Interfaces After “loading” activity JVM immediately perform Linking activity. Linking once again contain 3 activities, 1. Verification in java .class files we never getting these alert messages. What is the reason is inside JVM a special component is there i.e., Byte Code Verifier. This Byte Code Verifier is responsible to verify weather .class file is properly formatted or not, structurally correct or not, generated by valid compiler or not. If the .class file is not generated by valid compiler then Byte Code Verifier raises runtime error java.lang.VerifyError. This total process is done in verification activity. 2. Preparation In preparation phase, JVM will allocate memory for class level static variables and assigned default values. E.g. For int ---> 0, For double ---> 0.0, For boolean ---> false Here just default values will be assigned and original values will be assigned in initialization phase. 3. Resolution Next phase is Resolution. It is the process of replacing all symbolic references used in our class with original direct references from method area.
  • 6. Run Java Program - Initialization • In Initialization activity, for class level static variables assigns original values and static blocks will be executed from top to bottom. • While Loading, Linking and Initialization if any error occurs then we will get runtime Exception saying java.lang.LinkageError. Previously we discussed about VerifyError. This is the child class of LinkageError.
  • 7. Types of class loaders in class loader subsystem 1. Bootstrap class loader/ Primordial class loader Bootstrap class loader is responsible for to load classes from bootstrap class path. Here bootstrap class path means, usually in java application internal JVM uses rt.jar. All core java API classes like String class, StringBuilder class, StringBuffer class, java.lang packages, java.io - enthusiast about java & open-source? packages etc are available in rt.jar. This rt.jar path is known as bootstrap class path and the path of rt.jar is jdk --> jre --> lib --> rt.jar This location by default consider as bootstrap class path. This Bootstrap class loader is responsible for loading all the classes inside this rt.jar. This Bootstrap class loader is implemented not in java it is implemented by native languages like C, C++ etc.
  • 8. 2. Extension class loader The extension class loader is the child of bootstrap class loader. This class loader is responsible to load classes from extension class path jdk --> jre --> lib-->ext -->*.jar The extension class loader is responsible for loading all the classes present in the ext folder. This Extension class loader is implemented in java only. The class name of extension class loader is sun.misc.Launcher$ExtClassLoader.class 3. Application class loader/System class loader The Application class loader is the child of Extension class loader. This class loader is responsible to load classes from Application class path. Application class path means classes in our application (Environment variable class path). It internally uses environment vatiable path. This Application class loader is implemented in java only. The class name of extension class loader is sun.misc.Launcher$AppClassLoader.class
  • 9. Example public class LoaderTest { public static void main(String[] args) { System.out.println(String.class.getClassLoader()); System.out.println(Employee123.class.getClassLoader()); System.out.println(LoaderTest.class.getClassLoader()); } } Output: null // Because Bootstrap class loader is not java object it is designed with C or C++ sun.misc.Launcher$ExtClassLoader@33909752 //Here i am created class Employee123 and create jar for this class and put in ext folder sun.misc.Launcher$AppClassLoader@73d16e93 Run Java Program - Invoking HelloWorld.main