java开发.exe工程,为什么不建议从Java程序创建.exe?

I am learning learn about GUI programming with Java, and I am using the Netbeans IDE. I would now like to create an executable program to run outside of Netbeans; i.e. so that it can be run from my desktop.

But when I did some research, I got the impression that creating an .exe from Java program is not recommended. Would you please explain to me why it is not recommended?

解决方案

It is not recommended because:

The standard Java tool chains do not support it.

An exe is not portable. Different exe formats are used for different operating systems, hardware architectures, etcetera.

A self-contained exe for a Java program needs to contain a full JRE. (Do you want to distribute 100Mb "hello world" executables?)

A Java exe with an embedded JRE is a security concern. There is no easy way to update the JRE ... to fix the latest batch of security holes.

If (hypothetically) the Java language, libraries and tool chain supported compilation to binary + linking, then distributing exe files would be a sensible solution. However, a lot of things that a Java application can do depend on standard Java's dynamic loading / JIT compilation implementation.

There have been / are third-party attempts to meet people's requirements for self-contained exe files, but your either end up with a Java subset1, or bloated exe files.

1 - For example, with the old GNU gcj compiler, the library was a subset of Java 2 (!) ... and (AFAIK) dynamic loading of bytecodes was not an option. For more information on gcj limitations, see this page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值