---
title: Classpath
slug: classpath
qid: 
snapshot: enwiki-001356813882
content_hash: 
license: CC BY-SA 4.0
source: https://en.wikipedia.org/w/index.php?oldid=1356813882
tags: [11060667, 128691585, 23117742, 23179496, 23374854, 26748027, 28493675]
---

# Classpath

> [!note] Provenance
> Snapshot `enwiki-001356813882` · content root `…`
> Derived from <https://en.wikipedia.org/w/index.php?oldid=1356813882> · Licensed CC BY-SA 4.0

Classpath is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable.

Classpath is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable. D:\myprogram>set CLASSPATH=D:\myprogram D:\myprogram>java org.mypackage.HelloWorld The rule is that -classpath option, when used to start the java application, overrides the CLASSPATH environment variable. If none are specified, the current working directory is used as classpath. This means that when our working directory is D:\myprogram\ (on Linux, /home/user/myprogram/ ), we would not need to specify the classpath explicitly. When overriding however, it is advised to include the current folder "." into the classpath in the case when loading classes from current folder is desired. The same applies not only to java launcher but also to javac, the java compiler.
