Java – Run application without classpath using Extension Mechanism

Last Updated on

In Java, it is possible to “extend” your currently installed JRE in a way that your classes are loaded automatically thereby removing the need to specify them in the classpath. This is done using Java’s Extension Mechanism.

Below is an image showing the general idea of the Extension Mechanism.


Overview of Extension Mechanism

Extensions are Jar files

Creating extensions is easy. All you need to do is bundle your classes into a JAR file.

Our Classes

We begin with two files – TurretaExtMainClass.java and TurretaExtSomeOtherClass.java. Nothing fancy. Just a main class that uses another class.

Create a Jar file

There are several ways to create jar files. Here, we’ll do the simplest and primitive way.

Note: this assumes that /path-somewhere/classes contains the com directory.

I am using Java 8 for this. You can check if you are using the correct platform.

This outputs

So, finally out extension is turreta-ext.jar which we will drop into the ext directory in Java home directory.

Drop it in the ext directory

Okay, make sure you are in the correct Java home directory.


Proceed to lib\ext directory under jre.


Test your App


You’ll notice my command prompt is “ms-dos:”. I changed it to keep things short.

Just type:








Karl San Gabriel

Professional Software Developer