getClass().getResource("...") does not work.
843806Feb 19 2008 — edited Feb 19 2008In a swing application I try to access resources such as a dictionary: "english.0" using getClass().getResource("/dict/english.0").
Ex:
File dictFile = new File(getClass().getResource("/dict/english.0").toURI());
File phonetFile = new File(getClass().getResource("/dict/phonet.en").toURI());
SpellDictionary dictionary = new SpellDictionaryHashMap(dictFile, phonetFile);
// continue doing other operations with dictionary...
This works fine as long as I am running the application locally in the IDE (netbeans 6.0) but when I distribute my application using a jar file it doesn't work.
dictFile.getPath() is returning
C:\Documents and Settings\gymartin\UnitTestManager\build\classes\dict\english.0. This should be a relative NOT Absolute Path right? Users using the jar file don't have this path in their PC, and I think that's the reason why it's not working. How can I fix this problem?
I appreciate your help guys!