title: Why is my URI not hierarchical?
body: <p>I have files in resource folder. For example if I need to get file from resource folder, I do like that:</p>
  
  <pre><code>File myFile= new File(MyClass.class.getResource(/myFile.jpg).toURI());             
  System.out.println(MyClass.class.getResource(/myFile.jpg).getPath());
  </code></pre>
  
  <p>I've <strong>tested</strong> and everything <strong>works</strong>!</p>
  
  <p>The  path is</p>
  
  <p>/D:/java/projects/.../classes/X/Y/Z/myFile.jpg</p>
  
  <p><strong>But</strong>, If I create jar file, using , <strong>Maven</strong>:</p>
  
  <pre><code>mvn package
  </code></pre>
  
  <p>...and then start my app:</p>
  
  <pre><code>java -jar MyJar.jar
  </code></pre>
  
  <p>I have that following error:</p>
  
  <pre><code>Exception in thread "Thread-4" java.lang.RuntimeException: ßâ«ßâößâÜßâ¢ßâ¥ßâ¼ßâößâáßâÿßâí ßâÆßâÉßâ£ßâ«ßâ¥ßâáßâ¬ßâÿßâößâÜßâößâæßâÉ ßâ¿ßâößâúßâ½ßâÜßâößâæßâößâÜßâÿßâÉ
  Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
          at java.io.File.&lt;init&gt;(File.java:363)
  </code></pre>
  
  <p>...<strong>and path of file is</strong>:</p>
  
  <pre><code>file:/D:/java/projects/.../target/MyJar.jar!/X/Y/Z/myFile.jpg
  </code></pre>
  
  <p>This exception happens when I try to get file from resource folder. At this line. Why? Why have that problem in JAR file? What do you think?</p>
  
  <p>Is there another way, to get the resource folder path?</p>