View all newsletters
Receive our newsletter - data, insights and analysis delivered to you
  1. What Is
January 20, 2023updated 27 Jun 2023 3:14pm

What is Java -cp?

Find out about the parameter used in Java.

By Tech Monitor Staff

Java ClassPath is an element contained in the Java Virtual Machine, also called Java compiler.

It is important not to confuse it with the Java Path, since their functions are totally different.

Virtual screen showing the programming of a website thanks to Java
Java helps compile code and programming. Image: Wright Studio/Shutterstock

What is Java ClassPath?

The ClassPath is defined as a parameter in the Java Virtual Machine (JVM), and it is controlled by a system or application called ClassLoader.

Its main function is to specify the location of classes and packages which are defined by the user.

This parameter can either be set via the command line or through an environment variable. The ClassPath can indeed specify a list of directories, Jar archives and Zip archives to search for class files.

What is the difference between ClassPath and Path?

The main difference between ClassPath and Path is that the latter is used exclusively for Java tools in programs like Javac, normally used to create and compile code. While ClassPath is controlled by System or Application class loader to find and compile Java bytecodes stored in the original class file.

In other words, Path is used by the computer’s operating system to find executable files, normally designated with .exe, and Java binaries. ClassPath is used by the application class loader to find .class files.

Content from our partners
How businesses can safeguard themselves on the cyber frontline
How hackers’ tactics are evolving in an increasingly complex landscape
Green for go: Transforming trade in the UK

Java ClassPath is considered one of the most important Java concepts, as it is how Java locates files.

Read more: This is how GPT-4 will be regulated

Topics in this article :
Websites in our network
Select and enter your corporate email address Tech Monitor's research, insight and analysis examines the frontiers of digital transformation to help tech leaders navigate the future. Our Changelog newsletter delivers our best work to your inbox every week.
  • CIO
  • CTO
  • CISO
  • CSO
  • CFO
  • CDO
  • CEO
  • Architect Founder
  • MD
  • Director
  • Manager
  • Other
Visit our privacy policy for more information about our services, how New Statesman Media Group may use, process and share your personal data, including information on your rights in respect of your personal data and how you can unsubscribe from future marketing communications. Our services are intended for corporate subscribers and you warrant that the email address submitted is your corporate email address.
THANK YOU