Reputation: 13108
The following line of code works fine with Eclipse
Path file = Paths.get(System.getProperty("user.home"),"Desktop","Peppe.txt");
however when I try to run it from a terminal it gives me back this error message
java.nio.file.NoSuchFileException: /root/Desktop/Peppe.txt
In theory System.getProperty("user.name")
should return a platform indipendent bit of root path? isn't it?
Upvotes: 0
Views: 1515
Reputation: 533530
You are running the code as root
and it's quite likely that root doesn't have a Desktop.
I wouldn't assume the code is not behaving correctly, instead I would assume you need to understand what it means.
Upvotes: 1