Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I am sort of stuck with an implementation that I have been asigned.It is a standalone runnable jar that I have to create from an eclipse project. This eclipse project runs fine when run from Eclipse IDE. But when I export it as a runnable jar and then when I run the jar using :
File f =new File("abc.properties");
the code searches in the folder in which I have placed my runnable jar and NOT WITHIN the jar itself.I want to ideally put evrythin in the jar file and then run only the jar file from command prompt.Because of this issue I have to keep the properties file with the jar file in the same folder so that my File IO picks it up.
Can anyone please suggest me a solution to put it in the jar and still use it.
You can use the getResource() or getResourceAsStream() APIs on the ClassLoader class to fetch resource. All you have to do is use the correct classloader and based on what you say, I think using the classloader of the class (@see Class.getClassLoader() API) from where you are looking up this file should work.