In an effort to make starting new projects easier, I've 'factored' out several classes I use regularly into a separate project in eclipse. I call this project the All-In-One. It holds a variety of abstract classes and OpenGL related methods I often reuse.
(All-In-One is included in the build path)
The issue I'm having is with another project, I'll call it the test project. I create an instance of the SimpleShader class in the test project ( referencing All-In-One ), but during runtime, it searches for default.vert and doesn't find it (java.io.FileNotFoundException)
I'm guessing it has to do with Parent Project not knowing about the shdr folder and its contents; or seeing that the class is 'created' in test project, it doesn't look in All-In-One's src folder. I've tried linking a folder to the shdr folder in the test project, but nothing changed.
All-In-One Project
src/
SimpleShader.java
shdr/
default.vert
.... other files
Test Project
src/
Here would be the main file that creates an instance of
SimpleShader, which then looks for default.vert (but can't find it)
I load the file with this
String filename = "shdr/default.vert"; // It's actualy passed via a parameter, but this works.
FileInputStream in = new FileInputStream(filename); // Boom java.io.FileNotFoundException:
Before creating a seperate project for all the major things, this worked just fine. I hope that it's just something simple that I don't know, or understand.
Thanks in advance.
Building on what Guenther said, I had tried that already without success. I did feel inspired and found that this worked.
String filename = SimpleShader.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm().substring(5)+filename;
Outputs somthing similiar to
/workspace/All-In-One/bin/shdr/default.vert