We have a simple desktop application which shows an about dialog with a path to our application and in some rare occasions of customers testing our application the following
try
{
final URL jarPath = ClassLoader.getSystemClassLoader().getResource( "." );
final Path parent = Paths.get( jarPath.toURI() ).getParent();//Here the exception occours.
}
catch( URISyntaxException ex )
{
...
}
results in this Exception:
java.lang.IllegalArgumentException: URI authority component has undefined host
at sun.nio.fs.WindowsUriSupport.fromUri(WindowsUriSupport.java:139)
at sun.nio.fs.WindowsFileSystemProvider.getPath(WindowsFileSystemProvider.java:92)
at java.nio.file.Paths.get(Paths.java:138)
Unfortunatly I wasn´t able to reproduce this error with our local enviroment. My first guess was, that the application was started from a network drive which was not locally mapped, but the dialog even handled UNC Pathes correctly.
Can anyone tell me, when this can fail with this exception? Or even a better way to determine the current application path, which also works on enviroments like network drives?