简体   繁体   English

如何为Windows PC部署Java应用

[英]How to deploy java app for Windows pc

I have studied Java Web Start and found it complex and clumsy for my purposes. 我研究了Java Web Start,发现它复杂而笨拙。 In addition, my app needs to access the PC resources, which causes more hoops to be jumped through with Java Web Start. 另外,我的应用程序需要访问PC资源,这会导致Java Web Start跳过更多的障碍。 To add to the difficulties I need to access a 32-bit native library (libvlc) so I need to insure that my app runs under 32-bit Java. 为了增加困难,我需要访问32位本机库(libvlc),因此需要确保我的应用程序在32位Java下运行。 Is there an easy way to deploy my app without resorting to Java Web Start? 有没有一种无需借助Java Web Start即可部署应用程序的简便方法吗? Needless to say, I want everything to be contained in a single .exe file. 不用说,我希望所有内容都包含在一个.exe文件中。

I would start by searching the Internet for keywords such as " java 2 exe " and " jar to exe ", etc. Doing so yields many freely available software packages that convert Java programs into Windows executables, for example: 我将从互联网上搜索诸如“ java 2 exe ”和“ jar to exe ”之类的关键字开始。这样做会产生许多免费的软件包,这些软件包将Java程序转换为Windows可执行文件,例如:

And the list goes on. 而这样的例子不胜枚举。 Perhaps one of them meets your needs? 也许其中之一可以满足您的需求?

I am answering my own question to help people understand how to do this, which has taken me some number of days to figure out. 我正在回答自己的问题,以帮助人们了解如何执行此操作,这花了我几天的时间才能弄清楚。

My initial problem was that my app would run on some versions of Windows but on others it was having problems finding the libvlc native library. 我最初的问题是我的应用程序可以在Windows的某些版本上运行,但是在其他版本上却找不到libvlc本机库。 I finally figured out that my app must run with 32-bit Java in order to use the 32-bit native library. 我终于弄清楚我的应用程序必须与32位Java一起运行才能使用32位本机库。 Thus, the problem then became how to insure that the user started my app with 32-bit Java. 因此,问题就变成了如何确保用户使用32位Java启动我的应用程序。

I read about Jar2Exe ( http://www.regexlab.com/en/jar2exe/ ) in another post and decided to check it out. 我在另一篇文章中了解了Jar2Exe( http://www.regexlab.com/en/jar2exe/ ),并决定对其进行检查。 It is a great little program that is very configurable so I figured that it must be able to handle my 32-bit Java problem. 这是一个很棒的小程序,可配置性很强,所以我认为它必须能够处理我的32位Java问题。 In fact, it does so without even needing to do any configuration. 实际上,它甚至不需要进行任何配置。 The resulting .exe file contains my app along with all the required jar files and starts up with the 32-bit Java. 生成的.exe文件包含我的应用程序以及所有必需的jar文件,并以32位Java启动。 I am very pleased with this program and plan to buy a license, which is very cheap. 我对该程序感到非常满意,并计划购买非常便宜的许可证。

Hope this saves time for other people who are trying to solve a similar problem. 希望这可以为其他尝试解决类似问题的人节省时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM