title: Can't access resource in a JAR on all computers
body: <p>I'm writing an application (specifically a plugin for the Bukkit Minecraft server). Doing this requires that I access a .properties file from the JAR of the application. This is where I encounter a strange problem. When I test the program on my development PC, it runs just fine. The .properties file gets loaded and everything is fine. However, on the other computer that I test it on, I try to start the app, and it can't loaded the properties, and the <code>InputStream</code> is <code>null</code>. Here is the method in which I load the file:</p>
  
  <pre><code>public class Points {
      private HashMap&lt;String, MessageFormat&gt; messages;
  
      public Points() {
           buildMessages();
      }
  
  public static void buildMessages() {
          Properties messageProps = new Properties();
          InputStream in = Points.class.getResourceAsStream("resources/messages.properties");
          messages = new HashMap&lt;String, MessageFormat&gt;();
          Enumeration en;
          try {
              messageProps.load(in);
          } catch(IOException ex) {
              System.err.println("Couldn't read message properties file!");
              return;
          } catch(NullPointerException ex) {
              System.err.println("Couldn't read message properties file!");
              if(in == null)
                  System.out.println("IOStream null");
              return;
          }
          en = messageProps.propertyNames();
          while(en.hasMoreElements()) {
              String key = (String)en.nextElement();
              String prop = messageProps.getProperty(key);
              MessageFormat form = new MessageFormat(prop.replaceAll("&amp;", 
                  "\u00a7").replaceAll("`", ""));
              messages.put(key, form);
          }
      }
  }
  </code></pre>
  
  <p>I've omitted some irrelevant code, but that is the gist of it. The structure of the JAR is as follows:</p>
  
  <pre><code>   com/
         pvminecraft/
             points/
                 Points.java &lt;-- The class where the file is loaded
                 resources/
                     messages.properties &lt;-- The file being loaded
  </code></pre>
  
  <p>On my PC the file is loaded from <code>resources/messages.properties</code>, but on the other file, the <code>InputStream</code> is null, and my <code>catch</code> block for the <code>NullPointerException</code> is run. What could be causing the problem, and how could I fix it? Thanks.</p>
  
  <p><strong>Update:</strong> Even using the full path (<code>/com/pvminecraft/points/resources/messages.properties</code>), the same issue is still persistent.</p>
  
  <p><strong>Update 2:</strong> Here is the full stack-trace:</p>
  
  <pre><code>java.lang.NullPointerException
      at java.util.Properties$LineReader.readLine(Properties.java:435)
      at java.util.Properties.load0(Properties.java:354)
      at java.util.Properties.load(Properties.java:342)
      at com.pvminecraft.points.Points.buildMessages(Unknown Source)
      at com.pvminecraft.points.Points.onEnable(Unknown Source)
      at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:188)
      at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:968)
      at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280)
      at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186)
      at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169)
      at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:436)
      at org.bukkit.Bukkit.reload(Bukkit.java:187)
      at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22)
      at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
      at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
      at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:374)
      at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:564)
      at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:541)
      at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
      at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
  </code></pre>
  
  <p>All of the <code>org.bukkit</code> and <code>org.craftbukkit</code> stuff is the server. The .properties file is loaded in the <code>buildMessages</code> method, called by the <code>onEnable</code> method of <code>Points</code>.</p>
  
  <p><strong>Update 3:</strong> On a fresh install of Arch Linux, the message properties file is loaded correctly and all is well. The remote server is Ubuntu Linux, and my dev PC is Arch.</p>
  
  <p><strong>Update 4:</strong> Alright, this is sort of a resolution. It seems to be a localized problem. I say that because I've managed to get access to two more computers, and the program runs correctly on both. While it's annoying, this doesn't seem to be anything wrong with my code or build scripts. I'm still wanting to know what's wrong, but it isn't pressing any more. I'll continue looking into this. Thanks everyone.</p>