如何为Java应用程序创建本机二进制文件? [英] How to create native binaries for your Java app?

查看:634
本文介绍了如何为Java应用程序创建本机二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将Java应用程序打包成Windows,Linux和Mac OS X的原生二进制文件。

I'm wondering how to package a Java application into a native binary for Windows, Linux and Mac OS X.

我知道Minecraft会这样做,但我可以弄清楚怎么做。这就是我想要做的:

I know Minecraft does this, but I can't figure out how. This is what'd I'd like to do:


  • 从NetBeans(最好)或Eclipse中,自动构建三个二进制文件。

  • 包含OpenGL等的本机库。所有。

  • 如果可能,对我的代码进行模糊处理。

如果有办法模仿我的世界自动更新程序功能,这将是非常棒的。

If there's some way to mimic the Minecraft auto-updater feature, that'd be totally awesome.

那么,有没有可用的工具为你做这个,或者我是否需要写大量的XML来完成这个?

So, are there any tools available to do this for you, or do I need to write a large bulk of XML to accomplish this?

推荐答案

要为Windows制作本机二进制文件,你可以使用像 Launch4J 。在OSX上,您可以使用 JarBundler 。 Minecraft只是为Linux分发jar文件。我不知道Linux的原生二进制打包器。

To make a native binary for Windows, you would use a tool like Launch4J. On OSX you could use JarBundler. Minecraft simply distributes the jar file for Linux. I'm not aware of a native binary packager for Linux.

你也可以通过GCJ编译你的Java代码,但这可能不是你想要的,因为有限制和兼容性问题。像Launch4j和JarBundler这样的本地捆绑包只是包装你的jar文件并使用真正的JRE来执行它。

You could also compile your Java code via GCJ but that's probably not what you want, as there are limitations and compatibility concerns there. The native bundlers like Launch4j and JarBundler simply wrap your jar file and use a real JRE to execute it.

至于与NetBeans或Eclipse集成,您可能必须编写自己的ant构建文件,特别是因为解决方案因平台而异。

As for integrating with NetBeans or Eclipse, you'll probably have to write your own ant build file, especially since the solution varies from one platform to the next.

这篇关于如何为Java应用程序创建本机二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆