Launch4j / windres: how to set paths correctly?

会有一股神秘感。 提交于 2019-12-01 08:45:13

I was facing the same problem and couldn´t set the path/classpath properly but as a workaround I create the Ant build within the launch4j directory and I was able to get it work generating the executable file.

For those that experience the:

error=2, No such file or directory

issue when running windres on 64-bit Linux, you will need to install 32-bit libraries. On Linux Mint I installed the package ia32-libs with:

sudo apt-get install ia32-libs

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.

I also had this problems and I fixed it by modifying the launch4j code.
In the Class Launch4JTask.java I replaced the line

final Builder b = new Builder(Log.getAntLog());

with this one

final Builder b = new Builder(Log.getAntLog(), new File(getOwningTarget().getProject().getProperty("launch4j.bindir")));

Through this change i could specify the path to Launch4j inside my ant build script like that

<property name="launch4j.bindir" location="../tools/launch4j/" />

Greetings, -chris-

I had similar problem with building launch4j in Maven:

...
[INFO] launch4j: (longPathIn.m2Repository)\windres.exe: can't popen `type  (longPathToTemp)\Temp\launch4j8580185391499327059rc': No error
[ERROR] 
net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Exec failed(1): [Ljava.lang.String;@9f1fb5
at net.sf.launch4j.Builder.build(Builder.java:145)
...

it started working normally after cleaning system variable ComSpec:

was: ComSpec=%SystemRoot%\system32\cmd.exe;c:\Program Files (x86)\NSIS\NSIS.exe
now: ComSpec=%SystemRoot%\system32\cmd.exe

It seems like NSIS inserted itself there, not me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!