OS platform has a different symbol used for path separator. Path separator is a symbol that separate one path element from the other. In Windows the path separator is a semicolon symbol (;
), you have something like:
.;something.jar;D:/libs/commons.jar
While in Linux based operating systems the path separator is a colon symbol (:
), it looks like:
.:something.jar:/libs/commons.jar
To obtain the path separator you can use the following code.
package org.kodejava.lang;
import java.util.Properties;
public class PathSeparator {
public static void main(String[] args) {
// Get System properties
Properties properties = System.getProperties();
// Get the path separator which is unfortunately
// using a different symbol in different OS platform.
String pathSeparator = properties.getProperty("path.separator");
System.out.println("pathSeparator = " + pathSeparator);
}
}