如何使用Java / Eclipse创建Windows .exe(独立可执行文件)? [英] How can I create a Windows .exe (standalone executable) using Java/Eclipse?

查看:521
本文介绍了如何使用Java / Eclipse创建Windows .exe(独立可执行文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢编程场景。现在使用C ++大约5个月,并决定我想开始进入Java。我使用Eclipse作为我的IDE,显然是Java的语言。我正在尝试编写一个简单的HelloWorld应用程序,它可以通过命令提示符执行。



在Visual Studio中,似乎创建可执行文件比较容易。我所要做的只是使用一个下拉箭头并选择发布,然后运行我的构建。希望能够在命令提示符下编写/运行Java的目的是为了在使用Swing之前,我可以练习一些语言基础知识。



所以底线,用Java编写命令提示符.exe最简单的方法是什么?



感谢提前!

解决方案

Java本身不允许构建一个 exe ,这将会失败其目的是跨平台。



AFAIK,这些是您的选择:


  1. 制作可运行的JAR 。如果系统支持并正确配置,则在GUI中,双击JAR将启动应用程序。另一个选择是写一个启动器shell脚本/批处理文件,它将使用适当的参数启动你的JAR


  2. 还有可执行的包装器 - 见如何将Java程序转换为.exe文件? / a>


另请参见:
将Java转换为EXE:为什么,何时,何时和如何


I'm new to the programming scene. Been working with C++ for about 5 months now, and have decided I want to start getting into Java. I'm using Eclipse as my IDE, and obviously Java for the language. I'm trying to write a simple HelloWorld application, which can be run through a command prompt executable.

In Visual Studio, it seems it's rather easy to create an executable. All I've ever had to do is use a pull down arrow and choose Release, and then run my build. The purpose of wanting to be able to write/run Java in command prompt is so that I'm able to practice some of the language basics before I go in full force with Swing.

So bottom line, what is the easiest way to create a command prompt .exe written with Java?

Thanks in advance!

解决方案

Java doesn't natively allow building of an exe, that would defeat its purpose of being cross-platform.

AFAIK, these are your options:

  1. Make a runnable JAR. If the system supports it and is configured appropriately, in a GUI, double clicking the JAR will launch the app. Another option would be to write a launcher shell script/batch file which will start your JAR with the appropriate parameters

  2. There also executable wrappers - see How can I convert my Java program to an .exe file?

See also: Convert Java to EXE: Why, When, When Not and How

这篇关于如何使用Java / Eclipse创建Windows .exe(独立可执行文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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