Member-only story
Core Java Tutorial
Do You Know Classpath In Java?
What is a classpath in Java and how to set it?
Sometimes knowing the basics of programming and the flow of execution for program files help us to understand the Language. Knowing the classpath is one of the basic concepts that every Java developer must know. I’m going to discuss what is classpath, how to set it, and how it helps JVM to execute class files.
What Is a Classpath?
The classpath is one of the core concepts in Java Programming and it’s often misunderstood or not understood at all by Java developers, especially beginners.
Simply put, the classpath is just a set of paths(or folders) where the Java Compiler and the JVM must find needed Classes to Compile or Execute the them.
How Classpath Helps JVM in Executing Class Files:
Let’s start with an example, suppose we have a Hello.java file that’s under the directory ~/Documents/codebase/testjava .
~/Documents/codebase/testjava> ll
total 8
-rw-r - r - 1 vgupta staff 129B Dec 7 11:17 Hello.java








