Java Examples - How to execute a specified class file directory (classpath)

Java 实例Java Examples

If our compiled Java class files are 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 HelloWorld's 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 实例Java Examples

Other extensions