title: Referencing files inside a JAR
body: <p>I am creating a Java app for some serial port communication and within the app's folder I have two resources that need to be present at run-time. The first is an image that is being used as a splash screen and the other is a configuration file that needs to be read as the program starts.</p>
  
  <p>Here is an abridged version of the output from the "tree" command in Linux, the two files that I need to be referencing are "commandSet.config" and "splash-screen2.png"</p>
  
  <pre><code>.
  ├── bin
  │   ├──...
  ├── commandSet.config
  ├── app-manifest.txt
  ├── splash-screen2.png
  └── src
      ├── events
      │   └── InterfaceEvents.java
      ├── models
      │   ├── Command.java
      │   └── Phone.java
      ├── operations
      │   ├── Application.java
      │   ├── ...
      └── views
          ├── CallDialog.java
          ├── SplashScreen.java
          └── Window.java
  </code></pre>
  
  <p>I am currently referencing in the following lines:</p>
  
  <pre><code>BufferedReader in = new BufferedReader(new FileReader("commandSet.config"));
  </code></pre>
  
  <p>and</p>
  
  <pre><code>JLabel image = new JLabel(new ImageIcon("splash-screen2.png"));
  </code></pre>
  
  <p>This works fine when I am running it from Eclipse, but as soon as I export to a runnable JAR the files are not moved and therefore aren't correctly referenced. I have tried moving them into the "src" folder, which resulted in them being archived within the JAR, but I still couldn't reference them. </p>
  
  <p>I'm pretty new to the concept of exporting Java projects, so maybe I have missed something obvious. If someone could show me the best way to do this and the best approach for future project file systems, I would be very grateful. Cheers!</p>