How to get the path to the executable when using launch4j?

前端 未结 5 1529
时光取名叫无心
时光取名叫无心 2020-12-17 22:46

I\'m using launch4j to wrap an executable jar file in my Windows application, but I need to pass references to some of its libraries in through the JVM arguments. The librar

5条回答
  •  太阳男子
    2020-12-17 23:11

    If I understand your question correct, you have a launch4j executable and a native library within your installation directory:

    /launch.exe
    /bin/lib.dll
    /lib/app.jar
    

    Now you want to start you app.jar with the generated launcher (launch.exe). You app loads the lib.dll.

    You can embed a file into your app.jar (marker.txt). Now you can use the ClassLoader

    http://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)

    getResource("marker.txt);
    

    This will give you something like:

    file://c://installdir/lib/app.jar!marker.txt
    

    This String can be parsed. But in fact, I think there should be a better solution for this problem.

提交回复
热议问题