将 Launch4J 配置为仅使用 32 位 JVM

发布于 2024-08-29 15:06:30 字数 199 浏览 3 评论 0原文

我正在使用 Launch4J 启动我的 Java 应用程序,如果系统上存在 x64 JRE,Launch4J 似乎更喜欢它。

不幸的是,我的应用程序无法在 64 位 JVM 上运行,因为我正在加载 32 位 DLL,这是不可能的,并且会导致 UnsatisfiedLinkError。

有没有办法强制/欺骗 Launch4J 仅使用 32 位 JVM?

I'm using Launch4J to start my Java application and if an x64 JRE is present on the system, Launch4J seems to prefer it.

Unfortunately my application cannot run on a 64 bit JVM because I'm loading a 32 bit DLL, which is not possible and leads to an UnsatisfiedLinkError.

Is there any way to force/trick Launch4J to use a 32 bit JVM only?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

篱下浅笙歌 2024-09-05 15:06:30

我有完全相同的问题:在 64 位环境中,如果安装了 32 位和 64 位 JDK/JRE,则此工具始终检测 64 位版本。
我已经修补了源(java + C++)代码以制作我自己的版本并重新编译所有代码。我添加了一个复选框以强制将 32 位 JDK/JRE 检测转移到 64 位 Windows 环境中。
只需下载该版本并将其用作原始版本即可。

版本: launch4j-3.0.2 -win32_Java32bitsDetection

I have exactly the same problem : Into 64 bits environment if both 32 ans 64 bits JDK/JRE are installed this tools always detect the 64 bits version.
I have patched the source (java + C++) code to make my own version and re-compile all. I add a check box to FORCE the 32 bits JDK/JRE detection into 64 bits windows environment.
Just donwload the version and use it as the original one.

Version : launch4j-3.0.2-win32_Java32bitsDetection

红尘作伴 2024-09-05 15:06:30

大约一年前,我使用 Lauch4J 包装一个需要 32 位 DLL(swt-win32.dll,正如它所发生的那样)的小型 Java 程序时遇到了这个问题。

我发现如果安装了 32 位和 64 位 JVM,Launch4J 总是会优先选择 64 位 JVM。只有卸载了 64 位 JVM 才有效,这显然不是一个实用的解决方案。

经过大量搜索并在其论坛上发布问题后,我发现没有办法让 Launch4J 更喜欢(并要求)32 位 JVM。

因此,我评估了许多替代 JRE 转换器(我使用了以下列表: http://www.excelsior-usa.com/articles/java-to-exe.html)。

我最终选择了 Jar2Exe,它是唯一具有我需要的功能的。它不是免费的,尽管有评估版,而且我认为它并不贵。

希望这有帮助!

I had this exact problem about a year ago, using Lauch4J to wrap a small Java program that required a 32-bit DLL (swt-win32.dll, as it happened).

I found that if there were 32-bit and 64-bit JVMs installed, Launch4J would always favour the 64-bit one. It would only work if the 64-bit JVM was uninstalled, which was obviously not a practical solution.

I found no way of getting Launch4J to prefer (and require) the 32-bit JVM, after searching quite a bit and posting questions on its forum.

Therefore, I evaluated a good number of alternative JRE converters (I used this list: http://www.excelsior-usa.com/articles/java-to-exe.html).

I ended up settling on Jar2Exe, which was the only one that had the features I needed. It's not free, though there is an evaluation version, and I think it wasn't expensive.

Hope this helps!

白昼 2024-09-05 15:06:30

我不知道Launch4J,但是您可以通过阅读System.getProperty(“os.arch”);来获取有关32/64的信息。如果您遇到 64 位系统,您可以退出安装程序并显示一条友好消息,告诉用户安装 32 位 JVM。

您可以使用包装器包装您的启动代码,以向用户显示消息框。

public static void main(String[] args]){

   String architecture = System.getProperty("os.arch");
   // Did not test the return value of this property,,but should work
   if("64".equals(architecture)){
       // Show a dialog, or print a logmessage
       System.exit(-1);
   }
   // Start my APP
   com.something.startup.main(args);
}

I don't know Launch4J, but you can get the Information about 32/64 by reading System.getProperty("os.arch");. If you encounter a 64-bit system you may quit the installer with a nice message, to tell the User to install a 32-bit JVM.

You may Wrap your startUp-Code with an Wrapper to show a Message-Box to the user.

public static void main(String[] args]){

   String architecture = System.getProperty("os.arch");
   // Did not test the return value of this property,,but should work
   if("64".equals(architecture)){
       // Show a dialog, or print a logmessage
       System.exit(-1);
   }
   // Start my APP
   com.something.startup.main(args);
}
蒗幽 2024-09-05 15:06:30

如果您不介意在您的应用程序中包含 JDK 的副本,请尝试将这些参数(在 MyApp.ini 中)传递给 launch4j:

-D32 -Djava.home=d:\MyApp\JDK32 -Djava.ext.dirs=d:\MyApp\JDK32\jre\lib\ext 

这里还可以使用其他内容:

如果您不打包 JRE ,您可以将 Launch4j 选项设置为使用“jreOnly”,然后使用名为“%ProgramFiles%”的 DOS 环境变量,您可以在预期位置找到 32 位或 64 位 JRE,具体取决于您是否使用SysWOW64 32 位 cmd.exe shell 或常规 64 位 shell。然后你可以将这些选项传递给 JVM:

-D32 -Djava.home=%ProgramFiles%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles%\Java\JREDIR\lib\ext 

或者

-D32 -Djava.home=%ProgramFiles(x86)%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles(x86)%\Java\JREDIR\lib\ext 

If you don't mind including a copy of JDK with your app, try passing these arguments (in the MyApp.ini) to launch4j:

-D32 -Djava.home=d:\MyApp\JDK32 -Djava.ext.dirs=d:\MyApp\JDK32\jre\lib\ext 

There are also other things going on here that you could use:

If you don't package the JRE, you can set the Launch4j option to use "jreOnly" and then, using the DOS environment variable called "%ProgramFiles%" you can locate the 32-bit or the 64-bit JRE in the expected location, depending on whether you used the SysWOW64 32-bit cmd.exe shell or the regular 64-bit shell. Then you can pass these options to the JVM:

-D32 -Djava.home=%ProgramFiles%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles%\Java\JREDIR\lib\ext 

or

-D32 -Djava.home=%ProgramFiles(x86)%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles(x86)%\Java\JREDIR\lib\ext 
绝影如岚 2024-09-05 15:06:30

我前段时间遇到了同样的问题并分叉了该项目,因此用户界面公开了一个强制应该找到 32 位 JVM 的选项,您可以从以下位置获取带有补丁的 launch4j 3.0.3 安装程序:

http://fbergmann.github.io/launch4j/files/SetupLaunch4j_3.0.3.exe

并在此处阅读更多信息:

http://frank-fbergmann.blogspot .de/2012/11/launch4j-for-32bit.html
http://fbergmann.github.io/launch4j/

I encountered the same problem some time ago and forked the project, so that the User interface exposes an option to force that a 32bit JVM ought to be found, you can grab the installer of launch4j 3.0.3 with the patch from:

http://fbergmann.github.io/launch4j/files/SetupLaunch4j_3.0.3.exe

and read more here:

http://frank-fbergmann.blogspot.de/2012/11/launch4j-for-32bit.html
http://fbergmann.github.io/launch4j/

心在旅行 2024-09-05 15:06:30

这是一个老问题,Launch4J 自提出以来已更新。现在有一个专用的用户界面控件用于选择首选的 JVM 版本。
目前的选项是:

  • 仅 64 位
  • 第一个 64 位,然后 32 位
  • 第一个 32 位,然后 64 位
  • 仅 32 位

最后一个,当然,正是 OP 所要求的。

Launch4J JVM选择对话框

This is an old question and Launch4J has been updated since it was asked. Now there is a dedicated user-interface control for selecting which version of the JVM to prefer.
The options currently are:

  • 64-bit only
  • First 64-bit, then 32-bit
  • First 32-bit, then 64-bit
  • 32-bit only

The last, one of course, is exactly what the OP requested.

Launch4J JVM Selection Dialog

柏拉图鍀咏恒 2024-09-05 15:06:30

对于像 Areca 这样的 Launch4j 应用程序的任何用户来说,如果被这个问题困扰,并且需要快速解决,请查看启动应用程序的目录,您将找到一个完整的 java 命令行来运行您的应用程序。名为 launch4j.log 的文件中的程序。只需使用您喜欢的 java vm 创建一个 bat 文件或脚本,然后使用日志中的完整命令行运行它。

For any users of Launch4j applications like Areca that get stung by this one, and need a quick work around, look in the directory where the application is launched and you will find a complete java command line to run your program inside a file named launch4j.log. Just make a bat file or script using the java vm you prefer and run it with the full command line in the log.

ゃ人海孤独症 2024-09-05 15:06:30

您必须在配置时添加 JVM 参数。

下面的帖子显示了如何添加它:

http://www.technimi.com/index.php?do=/group/java/forum/building-an-exe-using-launch4j-for -32位jvm/

You will have to add a JVM parameter while configuring.

It is shown in the below post on how to add it:

http://www.technimi.com/index.php?do=/group/java/forum/building-an-exe-using-launch4j-for-32-bit-jvm/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文