简体   繁体   English

从Java项目制作可运行程序的简单方法

[英]Easy way to make a runnable program out of a java project

Im doing a small Java project with some school kids to teach them programming and at the end of this project hopefully we will have a small Game. 我正在和一些在校的孩子一起做一个小的Java项目,教他们编程,希望在这个项目结束时我们能做一个小游戏。 I would like to give these kids some sort of "exe" file(on an USB-Stick) that should run if you double click it. 我想给这些孩子一些“ exe”文件(在USB-Stick上),如果您双击该文件,该文件将运行。 I can produce a .jar file, but that wont execute on double clicking it. 我可以生成一个.jar文件,但是双击将无法执行。 The first thing i can think of is a .bat file with java -jar [game.jar] as content but this would require an installed JRE. 我可以想到的第一件事是一个以java -jar [game.jar]为内容的.bat文件,但这需要安装的JRE。 Is there any better(but not too complex) way to generate a file(or directory with file in it) that could run anywhere(on Windows is enough) like a portable JRE? 是否有更好的(但不太复杂)的方法来生成可以在任何位置(在Windows上足够)像便携式JRE上运行的文件(或其中包含文件的目录)?

The best solution would be a single File like a self-extracting zip. 最好的解决方案是像自解压zip这样的单个文件。

You can use Launch4j, it makes an .exe which tries to run the program and if no JRE is found it leads them to the download page of the JRE. 您可以使用Launch4j,它会生成一个.exe来尝试运行该程序,如果找不到JRE,它将导致他们进入JRE的下载页面。 I'm just not sure if it can make an .exe with embedded JRE. 我只是不确定它是否可以使带有嵌入式JRE的.exe。

Their website: http://launch4j.sourceforge.net/ 他们的网站: http : //launch4j.sourceforge.net/

Because you are using Java, which is dependent on the JRE to run, you are not going to get around not having the JRE installed without significant legwork. 由于您使用的是Java,这是依赖于JRE来运行,你是不会得到解决没有不显著跑腿安装JRE。 Just package instructions with the flash drives you give the kids! 只需将包装说明与您给孩子的闪存驱动器一起使用即可!

If you're committed though, look into http://www.excelsiorjet.com/ or http://www.duckware.com/jexepack/index.html . 不过,如果您决心这样做,请访问http://www.excelsiorjet.com/http://www.duckware.com/jexepack/index.html

As well as this SO question: How can I convert my Java program to an .exe file? 以及这个SO问题: 如何将Java程序转换为.exe文件?

I can produce a .jar file, but that wont execute on double clicking it. 我可以生成一个.jar文件,但是双击将无法执行。

Why doesn't this work? 为什么不起作用? Is it an issue with having a JRE present, and that these kids might not have it, or might not be able to install it on other's machines? 是否存在JRE是一个问题,而这些孩子可能没有它,或者可能无法将其安装在其他人的计算机上?


I suggest you go here if you want go the "exe" route. 如果您要执行“ exe”路径,建议您去这里。

http://www.excelsiorjet.com/free http://www.excelsiorjet.com/free

if you click "free licenses" you can get apply for a free license of I believe the "standard edition." 如果单击“免费许可证”,则可以申请一个我认为是“标准版”的免费许可证。

This should be "Good enough" for your intended purposes, and you wont need a JRE present. 对于您的预期目的,这应该足够好,并且您不需要JRE。

It's more work on your end, but it should work nicely for your needs. 这需要您做更多的工作,但可以很好地满足您的需求。

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

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