Friday, June 24, 2016

6/24

After cleaning my project, I couldn't get my uploaded package to recognize my recipe and url file anymore. Although there are countless stack overflow forums on this, it took me hours to get it working! I spent forever going over different solutions, different ways to try importing the file, different ways to attach it to my pom.xml, different places to put the file, etc. I'm going to upload these changes to github and hopefully it'll work for more than just me!

EDIT: I went through and tested what change actually made it work. I had properly included the resource, I just wasn't reading form it properly. I had previously accessed it by using

InputStream is = RecipeSetup.class.getResourceAsStream("MASTER_RECIPE.txt"); but this did not work. I think it's because I was supposed to use a getClass method on my main function, but I wasn't calling it from main. Instead, I needed to get the classLoader using:

ClassLoader loader = Thread.currentThread().getContextClassLoader();

InputStream is = loader.getResourceAsStream("MASTER_RECIPE.txt");

No comments:

Post a Comment