java.nio.file: Where is the Path interface actually implemented?

Inside NetBeans IDE, you can view the implementation details of Paths class by doing the following:

  • Step one:

    click your cursor on the line where you have written your Path code. An example Path would be:

Path p = Paths.get("someDir\someOtherDir");

  • Step Two:

Click Debug | Step Into (F7)

It will bring up the implementation details of Paths


If you look carefully you will notice that the method getPath from FileSystem object returns implementation of Path interface. By invoking FileSystems.getDefault() you will retrieve implementation of FileSystem interface which will depend on system. On Linux system you will get LinuxFileSystem object witch extends UnixFileSystem class.

You can look for example at UnixFileSystem class from openjdk which is implementation of FileSystem interface.

Here is the link with implementation of getPath method from UnixFileSystem, which will return instance of UnixPath.

You must remember that FileSystems.getDefault return implementation dependent on the operating system. Furthermore source code of those classes isn't available in oracle jdk.