Part of an application that I've been working on gets a file from the local machine with the following code:
To simplify things, I've put the files in the same package directory as the classes that read and write to them. This works fine when run from Eclipse and when run from the command line. However, once I put all the package directories in a jar file with a manifest that specifies the main class I get the following error when I run it (using java -jar filename.jar)Code:URL url = getClass().getResource( fileName ); File thisFile = null; try { // Convert URL to URI and use to create File thisFile = new File( url.toURI() ); } catch ( URISyntaxException e ) { e.printStackTrace(); }
The top of the stack trace output refers to the line of code highlighted in red. Does anyone know what this error means?Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierarchical
Thanks.


Reply With Quote


Bookmarks