1

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?

crusam
  • 6,140
  • 6
  • 40
  • 68
  • What is the URL returned by jarPath? – fge Nov 30 '15 at 17:07
  • Here's [the source](https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/windows/classes/sun/nio/fs/WindowsUriSupport.java#L139). – Kenney Nov 30 '15 at 17:12
  • When I print the URL it shows file://[servername]/transfer/[applicationname]/app but this is the working case, started from a network drive. Unfortunatly I don´t know the value before it fails, since I can´t yet reproduce the error. – crusam Nov 30 '15 at 17:18
  • thanks for the sources! I will have a look! – crusam Nov 30 '15 at 17:19

0 Answers0