title: URI is not hierarchical exception when running application from JAR
body: <p>I've exported my Java console application to a Jar file, but when I run the jar and call code that parses in a JSON file I get a <code>java.lang.IllegalArgumentException</code></p>
  
  <p>Does anyone know why the exception is being thrown when I run the program as a JAR? The parsing works fine when the application is run from Eclipse.</p>
  
  <p>This is the exact error that is output when I execute the jar file and call the code that parses the JSON file:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierar
  chical
          at java.io.File.&lt;init&gt;(Unknown Source)
          at gmit.GameParser.parse(GameParser.java:44)
          at gmit.Main.main(Main.java:28)
  </code></pre>
  
  <p>This is how the parsing is being done in my GameParser class:</p>
  
  <pre><code>public class GameParser {
      private static final String GAME_FILE = "/resources/game.json";
      private URL sourceURL = getClass().getResource(GAME_FILE); 
      private int locationId;
  
      private List&lt;Location&gt; locations;
      private List&lt;Item&gt; items;
      private List&lt;Character&gt; characters;
  
      public void parse() throws IOException, URISyntaxException {
          ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  
          try {                   
              // read from file, convert it to Location class
              Location loc = new Location();
              loc = mapper.readValue(new File(sourceURL.toURI()), Location.class);
              Item item = mapper.readValue(new File(sourceURL.toURI()), Item.class);
              GameCharacter character = mapper.readValue(new File(sourceURL.toURI()), GameCharacter.class);
  
              // display to console
              System.out.println(loc.toString());
              System.out.println(item.toString());
              System.out.println(character.toString());
          } catch (JsonGenerationException e) {
              e.printStackTrace();
          } catch (JsonMappingException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>This is the folder structure of my project:</p>
  
  <p><img src="https://i.stack.imgur.com/YkV4t.png" alt="source tree"></p>