Possibly :)

# On Unix
java -cp utilities.jar:. mypackage.MyClass

# On Windows
java -cp utilities.jar;. mypackage.MyClass

Basically that's just including . (the current directory) on the classpath as well as the jar file.

Answer from Jon Skeet on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › environment › paths.html
PATH and CLASSPATH (The Java™ Tutorials > Essential Java Classes > The Platform Environment)
To set the path permanently, set ... named by the environment variable, ENV. To set the path: ... The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes....
🌐
Medium
medium.com › javarevisited › back-to-the-basics-of-java-part-1-classpath-47cf3f834ff
Tutorial on how Java classpath works | Javarevisited
May 15, 2022 - Which we know exists, so the program runs successfully. Now let’s change it up a little bit. Let’s add a new folder lib on the same level as bin and move the Utils.class so that it now looks like this. ClasspathProject/ | ---> src/java/myprogram/ | ---> Main.java | ---> utils/ | ---> Util.java | ---> bin/myprogram/ | ---> Main.class | ---> lib/myprogram/ | ---> utils/ | ---> Util.class
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › tools › windows › classpath.html
2 Setting the Class Path
April 21, 2026 - For example, suppose you want the ... path so that it contains C:\java\MyClasses. To run that application, you could use the following java command: java -classpath C:\java\MyClasses utility.myapp.Cool...
🌐
Oracle
docs.oracle.com › javase › › 7 › docs › technotes › tools › windows › classpath.html
Setting the class path
The class search path (more commonly known by the shorter name, "class path") can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually ...
🌐
HowToDoInJava
howtodoinjava.com › home › java examples › java – set classpath from command line
Java - Set Classpath from Command Line
January 25, 2022 - Use -classpath or -cp option to provide the classpath locations while starting the Java application or tool. ... Use set CLASSPATH command initially, and then run Java application or tool in the same command line window.
🌐
Edureka
edureka.co › blog › set-java-classpath
How To Set Classpath In Java | Java Path And Classpath | Edureka
June 19, 2023 - Whenever a Java application executes it checks for Java classes in CLASSPATH in order to execute without any error. It commonly contains paths to Jar files with OS path separator in windows it is ‘;’. If you want to specify classpath while running any program using command line you can use Java -cp “some.jar;someOther.jar” com.edureka.HelloWorld .
Find elsewhere
🌐
Mcmaster
cas.mcmaster.ca › ~lis3 › javatutorial › Classpath.htm
java tutorial, CLASSPATH, -classpath, -d
... It is a good practice to organize the classes and source files in different directories. Set the environment variable CLASSPATH to the root directory where class files will be stored. When compile, use -d $CLASSPATH option to store the class files in the appropriate directories.
🌐
How to do in Java
howtodoinjava.com › home › java basics › java classpath
How to set CLASSPATH in Java - HowToDoInJava
February 23, 2023 - ... Apart from setting the classpath to the environment variable, you can pass an additional classpath to Java runtime while launching the application using –classpath option or –cp option.
🌐
DEV Community
dev.to › martingaston › understanding-the-java-classpath-building-a-project-manually-3c3l
Understanding the Java Classpath: Building a Project Manually - DEV Community
July 27, 2019 - Essentially, our classpath needs to contain the path to our .jar files to the top of our package hierarchies. It can be set either via environment variable, which you shouldn't do, or with the much better option of the -cp flag. It also helps explain a common Java gotcha, where you try and run java without cd'ing into the directory first.
🌐
GeeksforGeeks
geeksforgeeks.org › java › different-ways-to-set-a-classpath-in-java
Different Ways to Set a Classpath in Java - GeeksforGeeks
July 23, 2025 - Enter Variable name :classpath [Don't give space between class path] Variable value:<directory_location>(for example in my F:\workspace\bin) Click OK->OK->OK. Close all windows, open a new command prompt, and run the java command
🌐
Michigan State University
web.pa.msu.edu › reference › jdk-1.2.2-docs › tooldocs › solaris › classpath.html
Setting the class path
The class path can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and ...
🌐
Medium
medium.datadriveninvestor.com › java-classpath-know-it-and-use-it-correctly-2cf6e4dc87ee
Java Classpath, know it, and use it correctly! | by Tom Henricksen | DataDrivenInvestor
June 29, 2022 - In other words, I ran through some ... issues with the CLASSPATH. Talking about Java it is best to get your information from the source, Oracle. They describe the classpath this way, “The classpath tells the JDK tools and applications where to find third-party and user-defined classes that are not extensions or part of the Java platform.” Essentially this is how Java looks for code to run...
🌐
Stack Overflow
stackoverflow.com › questions › 47471305 › run-java-program-classpath
eclipse - Run java program classpath - Stack Overflow
November 26, 2017 - If you run your java program from any IDE like Eclipse or any another do not need to explicitly set environment variable CLASSPATH or PATH but if you try to run from terminal (in unix/linux/mac) or from command prompt ( in windows) you have ...
🌐
Blogger
javarevisited.blogspot.com › 2011 › 01 › how-classpath-work-in-java.html
How to Set Classpath for Java on Windows and Linux? Steps and Example
Here is the reason for these Java classpath errors: ClassNotFoundException is an Exception and will be thrown when the Java program dynamically tries to load a Java class at runtime and doesn’t find the corresponding class file on the classpath. Two keywords here are “dynamically” and “runtime”. A classic example of these errors is when you try to load the JDBC driver by using Class.forname(“driver name”) and are greeted with java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
🌐
Wikipedia
en.wikipedia.org › wiki › Classpath
Classpath - Wikipedia
May 30, 2026 - The classpath tells Java where to look in the filesystem for files defining these classes. The virtual machine searches for and loads classes in this order: bootstrap classes: the classes that are fundamental to the Java Platform (comprising the public classes of the Java Class Library, and the private classes that are necessary for this library to be functional). extension classes: packages that are in the extension directory of the Java Runtime ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › run-java-class-file-different-directory
How to run java class file which is in different directory? - GeeksforGeeks
May 7, 2019 - How to run a java class with a jar in the classpath? You can also use jar file instead of class files from different classpath. The process will be same, you just have to replace classes folder with jar folder and class name with jar name.
🌐
Oracle
docs.oracle.com › javase › tutorial › deployment › jar › downman.html
Adding Classes to the JAR File's Classpath (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)
The following is an example of the Class-Path manifest attribute: Class-Path: servlet.jar infobus.jar acme/beans.jar images/ By using the Class-Path attribute in your application's JAR file manifest, you can avoid having to specify a long -classpath flag when launching java to run your application.
🌐
Lenovo
lenovo.com › home
Java Classpath: Definition, Usage, Options & Best Practices | Lenovo US
The -cp or -classpath option allows developers to specify a custom classpath directly on the command line when compiling or running Java programs. It overrides any classpath environment variable, ensuring the provided paths are used for locating class files and resources.