ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Using wildcards in java classpath

Wild cards were introduced from Java 6. Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For ex. a classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

Example

java -cp "lib/*" %MAINCLASS% where %MAINCLASS% is the class containing your main method.

How to use a wildcard in the classpath to add multiple jars

java -cp "lib/*" -jar %MAINJAR%

where %MAINJAR% is the jar file to launch via its internal manifest.

If you need only specific jars, you will need to add them individually. The classpath string does not accept generic wildcards like Jar, *.jar, hiber etc.

Example

The following entry does not work:

java -cp "Halo.jar;lib/*.jar" ni.package.MainClass

Correct entry is :

java -cp "Halo.jar;lib/*" ni.package.MainClass

More about....Java Classpath

Ling