Thanks Jeff, it works.
But only if I run the JRE in the console from the same directory of the jar/class files, otherwise it returns the working path of the java executable.
It works also if I prepare a shortcut with the given working directory in Windows.
Right because if you double click a document in Windows, the CWD is set to the dir of the executing program.
So yes if you don't do something to make sure your CWD is set right (eg set by a shortcut or run from the console after you CD to the app dir) you wont get the right answer.