Launch4j / windres: how to set paths correctly?

后端 未结 5 838
轮回少年
轮回少年 2021-01-14 09:40

I have launch4j configure for my project. I used it back, when i developed on windowsXP, where it worked. Now i need it to build on mac as well:

My build.xml:

<
5条回答
  •  被撕碎了的回忆
    2021-01-14 10:17

    This error occurs when your current directory is not the launch4j directory, as Leo noted.

    Launch4j attempts to find its own install directory by looking on the classpath for launch4j.properties. This is done in Util.java, at the top of the getJarBaseDir() method. It was changed recently to have these lines:

    URI uri = new URI(Util.class.getClassLoader()
        .getResource(Launch4jProperties)
        .getFile());
    
    String path = uri.getPath();
    
    if (path.startsWith("file:")) {
      String jarPath = path.substring(5,path.lastIndexOf('!'));
    

    The problem is uri.getPath() does not return the "file:" part for local file URIs--it only returns the path portion of the URI beginning with /. I changed those last two lines to this, and it started working:

    if (path.startsWith("/")) {
      String jarPath = path.substring(0, path.lastIndexOf('!'));
    

    Note the 5 -> 0 in substring because we don't need to remove "file:" part anymore. I had to rename build.xml.prod to build.xml in order to compile launch4j, but other than that it worked fine.

提交回复
热议问题