What does exactly mean this sentence from this oracle java tutorial:
A relative path cannot be constructed if only one of the paths includes a root
As other answers already mentioned this is due to the different roots in the path.
To work around that, you can use toAbsolutePath().
For example:
public class AnotherOnePathTheDust {
public static void main (String []args)
{
Path p1 = Paths.get("home").toAbsolutePath();
Path p3 = Paths.get("/home/sally/bar").toAbsolutePath();
Path p1_to_p3 = p1.relativize(p3);
Path p3_to_p1 = p3.relativize(p1);
System.out.println(p3_to_p1);
}
}