java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to get path / classpath separtor?

OS platform have different symbol used for path separator. Path separator is a symbol that separate one path element from the other. In Windows you have something like:


While on Linux operating system it looks like:


To obtain the path separator you can use the following code.


import java.util.Properties;

public class SystemProperties
    public static void main(String[] args)
        // Get System properties
        Properties properties = System.getProperties();

        // Get the path separator which is unfortunatelly
        // using a different symbol in different OS platform.
        String pathSeparator =
        System.out.println("pathSeparator = " + pathSeparator);