1

I need an executable jar for my program. A part of the program contains the Gate entity extraction tool. Here is the part of the code:

ClassLoader classLoader = getClass().getClassLoader();

File file = new File(classLoader.getResource("annie.gapp").getFile());  
// CorpusController application = (CorpusController) PersistenceManager.loadObjectFromFile(
        //new File("annie.gapp"));

CorpusController application = (CorpusController) PersistenceManager.loadObjectFromFile(
        file);

In eclipse everything is working, but if I export it as executable jar file it does not find the annie.gapp file, and I don’t know how to make it work (I have already looked here on Stackoverflow)

sp0030
  • 109
  • 1
  • 6
  • 1
    How do you export as executable jar? – StephaneM Feb 02 '18 at 13:36
  • I exported it from eclipse. export - java - runnable jar file. The annie.gapp file and everything from gate gets exported but loading the file does not work – sp0030 Feb 02 '18 at 13:38
  • 1
    ok, I could solve it. Instead of loadObjectFromFile it is possible to load annie.gapp from an URL (loadObjectFromUrl) – sp0030 Feb 02 '18 at 14:25
  • 1
    A .jar file is a single archive file. Entries in a .jar are not files. You cannot refer to them as files. And the URL.getFile() does not convert a URL to a file name, it just returns the path portion of a URL. – VGR Feb 02 '18 at 16:25

0 Answers0