title: Opening files located in Java jar directory, not Current Working Directory
body: <p>I have a <strong>Java desktop application</strong> that I developed in NetBeans which I zip up to distribute to students.  Inside this zip file I have the <strong>.jar</strong>, a "lib" directory that contains the swing-layout jar, and a directory I named "sourcefiles" that contains all the text files needed for the program.   </p>
  
  <p>All works fine if the jar file is double clicked, but when run from the <strong>command line</strong> (<code>java -jar MyApp.jar</code>), it <strong>can only find the "sourcefiles" directory</strong> if you first cd to the directory that the file is in before running the command, something that the some students forget to do.  Apparently there is no way to change the current working directory from within my code.  The path to "sourcefiles" is given in my code as a <strong>relative path</strong>, assuming that I am in the <strong>MyApp</strong> folder.   So what can I do so that the program can be run from the command line without having to <strong>cd</strong> to the containing directory?  Is there something to add this to the manifest file?</p>
  
  <p>This problem is faced mostly by students using Linux, but it is the same on Mac.  I assume it's the same on Windows, but I guess none of the students with Windows run it from the command line.</p>