Incorrect basedir in Ant build

  • Victor Denisov
    Victor Denisov

    I'd recently tried to incorporate launch4j into my Ant build process (I'd used to manually generate new .exe files from the GUI before that). Unfortunately, launch4j target failed during invocation of LD, telling me that it couldn't find appropriate libraries. To make a long story short, I'd narrowed this issue down to the following lines in

    URI uri = new URI(Util.class.getClassLoader()
    String path = uri.getPath();
    if (path.startsWith("file:")) {
            //Compute basedir
    } else {
           return new File(".");

    Basically, in my environment (Windows 7 64-bit, JDK 1.7.0_09 64-bit), I don't get a path which starts with "file:" (I get "/c:/Dev/lib/launch4j/launch4j.jar!/" instead), so the base dir is always being set to current dir - which works for a stand-alone GUI application, but fails for Ant target.

    Hope this would be fixed in a future launch4j release.

    Victor Denisov.

  • Scott Plante
    Scott Plante

    Ah ha, I came to the same conclusion. I wish I'd seen this before. I'm going to add the following error message so this might turn up on some additonal searches:

    net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Cannot run program "./bin/windres": error=2, No such file or directory

    I added a blurb similar to yours to the bug I found (3606889).

  • Grzegorz Kowal
    Grzegorz Kowal

    Fixed in 3.0.1-beta2.