• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

Difference between Path and Classpath Environment Variable in Java

Aniruddha Chaudhari/16041/0
CodeDifference BetweenJAVA

These are very important variables in Java. Once you have installed Java JDK toolkit, it is necessary to set path & classpath. It is one-time setup that will help you throughout running all Java applications. In this post, we see the difference between path and classpath environment variable in Java.

It is simply variable that contain links to tools and classes provided by JDK system.

There are two types of the environment variable we need to set for Java:

  • Path variable
  • Classpath variable

The difference between Path and Classpath environment variable in Java:

Let’s dwell on each of the variable first…

Path Environment Variable in Java

The path is variable to provide the path of tools that we used while working on any Java program. It contains all the directories path.

There are multiple java tools we use. Some of the important tools we use in java are…

  • java– It is used to run Java program.
  • javac – It allows to compile Java program.
  • javap – It dis-assemble a class file so that it will display end user all the fields, constructors, methods present in the class for the end user.
  • javah – It allows interacting Java application with C code, jar- combined multiple Java files into single jar archive file.
  • appletviewer – It allows to run the applet in Java outside of the web browser.

You can find JDK Hierarchy in the following image. That shows availability of Java tools and classes in JDK directories.

JDK folder Hierarchy to setup Path and Classpath environment variable in Java

Classpath Environment Variable in Java

It is variable that provides link path to all classes which we require in our application.

For Java, all classes provided by system presents in lib /rt.jar files. So it is very necessary to locate the path of these classes before actually using in our application.

Path Vs Classpath Environment Variable

Though both are the environment variable that contains directory paths, there is a difference between path and classpath variables in Java.

Path Environment Variable Classpath Environment Variable
It contains a path to the java tools. It contains a path of the classes provided by JDK.
Java tools include java, javac, javap, javah, jre… All the classes are available in “rt.jar” file.
Command to check path: >>echo %path% Command to check classpath: >>echo %classpath%

Wrapping up…

I have seen many geeks getting confused on setting up path and classpath variables in Java. I expect from this post you got a complete understanding of the difference between Path and Classpath environment variable in Java.

If you want to setup these two variables in your system for Java, do read step by step complete guide for JDK installtion.

Happy Programming!

classpathJavaJava JDK
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Leave a Reply Cancel reply

Interview Questions



You can share your interview experience.

Subscribe for FREE Newsletter

Do you want me to send you programing updates for FREE?

Subscribe below…

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard