title: Eclipse - Reference file in another Project
body: <p><strong>Edit:</strong> My solution at bottom of post.</p>
  
  <p>I have 2 projects that share the same XML/XSD data in eclipse.  I've tried many different things to break the data into a separate project and just reference that instead through various methods, with not much luck.  My goal is so I can click run in eclipse for each project separately and they both load from the same data.</p>
  
  <p>When the project is finally built, there will be 3 jars (the two projects,+ a lib), which will be in the same directory with the xml and xsd folders.  So any file references to the XSD/XMLs are currently in the format like this: </p>
  
  <pre><code>File file = new File("xml/pixtilemaps.xml");
  </code></pre>
  
  <p>This doesn't work in eclipse, but works during export because of the file structure is sound.  I tried using virtual folders in each of the projects, but it doesn't look like runtime references to relative files use the virtual folders in the way I was expecting.  I've tried adding each as a linked resource, added the project on the build path, etc, but whatever I do, it doesn't seem to treat the xml folder as a relative folder.  I get an error like : file:/F:/workspace/com.myoid.editor/xsd/pixtilemaps.xsd does not exist.  Because it takes it relative to the project. I've also tried to find a run configuration solution to this, but there is obviously something I'm not understanding to get this to work the way I want.  </p>
  
  <p>So in summary, have an xsd folder, xml folder in a 3rd eclipse project, that I want 1 and 2 to be able to access through relative file paths like</p>
  
  <pre><code>File file = new File("xml/pixtilemaps.xml");
  </code></pre>
  
  <p><strong>How I fixed it:</strong></p>
  
  <p>Okay.. so.. maybe there is a better solution but this is what I came up with... In Eclipse under run configurations you can specify the working directory that the launch will run from.  So I put all xml/xsd in for both projects in the same "working directory".  In the run configuration for each project I point the working directory to the 3rd project, and viola, it works like I had expected.</p>