Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java Example – How to Execute a Specified Class File Directory (classpath)

Java Example – How to Execute a Specified Class File Directory (classpath)

Java Examples Java Examples

If our compiled Java class file is not in the current directory, we can use -classpath to specify the class file directory:


C:> java -classpath C:\java\DemoClasses HelloWorld

In the above command, we used the -classpath parameter to specify the directory where the HelloWorld class file is located.

If the class file is in a jar file, the command is as follows:


c:> java -classpath C:\java\myclasses.jar

Java Examples Java Examples