It's a design decision. The designers make decisions so that the language is easy to use and to reduce the probability of errors - allegedly!
You have to realise that neither toAbsolutePath() nor relativize() check the actual path+file exist. See below. If they don't care whether it exists or not, then it is irrelevant that you actually have a C:\java on your system.
These methods operate at the "logical" and not the "physical" level. If you want to use relativize() then it is up to you to create a Path object so that it is C:\java, and then call relativize() on that.
U1@Ahmed MINGW64 ~
$ java Test
Absolute path of p1: C:\a\b
Absolute path of p2: C:\a\b\c\d
Relative path of p2 to p1: c\d
U1@Ahmed MINGW64 ~
$ ls -ld C:/a/b
ls: cannot access C:/a/b: No such file or directory
U1@Ahmed MINGW64 ~
$ ls -ld C:/a/b/c/d
ls: cannot access C:/a/b/c/d: No such file or directory