使用 Eclipse 将 JavaFX 项目导出为可运行的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39710286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:17:51  来源:igfitidea点击:

Export JavaFX Project to a runnable using Eclipse

javaeclipsejavafx

提问by joe n

I'm using Eclipseand making a simple game in javaFX. I have images and need to package them and the javafx into a runnable file. I am not using any of the css stuff related to javafx, just the basic windows and stages and stuff. Thanks!

我正在EclipsejavaFX 中使用和制作一个简单的游戏。我有图像,需要将它们和 javafx 打包到一个可运行的文件中。我没有使用任何与 javafx 相关的 css 东西,只是基本的窗口和阶段等等。谢谢!

I have tried to just export it however it did not work.

我试图只是导出它,但它没有用。

采纳答案by GOXR3PLUS

  • Part 1

    A JavaFX Eclipse Project is like:

  • 第1部分

    JavaFX Eclipse 项目类似于:

enter image description here

在此处输入图片说明

So with the above you are sure that every library and resource will be in the

因此,通过上述内容,您可以确定每个图书馆和资源都将在

1)Into the final Jar

1)进入最终的Jar

or

或者

2)You will have a final Jar and a separate folder which contains all the external libraries you are using.

2) 您将有一个最终的 Jar 和一个单独的文件夹,其中包含您正在使用的所有外部库。

or

或者

3) (2)+External Folder for other resources

3) (2)+其他资源的外部文件夹

Exporting the Project:

导出项目:

1)Right Click on the Project

1)右键单击项目

2)Export->Java->Runnable Jar File...

2)Export->Java->Runnable Jar File...

enter image description here

在此处输入图片说明

3)Choose your main class

3)选择你的主要课程

4)On Library Handling it is your choice(better choose the 3rdoption cause it prevents conflicts on libraries which containing same classes and doesn't violate some libraries licence)

4)关于库处理它是你的选择(最好选择第三个选项,因为它可以防止包含相同类的库发生冲突并且不违反某些库许可)

5)Export It

5)出口

Finally

最后

Also have a look at this linkwhich was provided in the comments.

另请查看评论中提供的此链接

  • Part 2)

  • 第2部分)

After you have done the above you can use Launch4Jto package your jar file into an .exe file(for Windows)

完成上述操作后,您可以使用Launch4J将您的 jar 文件打包成 .exe 文件(适用于 Windows)

  • Part 3)

    You can also export your JavaFX Project in a way that it can be used in windows,Mac and Linux.

    For that you can use the file build.fxbuildand build the project(big topic search for it on internet)

  • 第 3 部分)

    您还可以以可在 Windows、Mac 和 Linux 中使用的方式导出 JavaFX 项目。

    为此,您可以使用文件build.fxbuild并构建项目(在互联网上搜索大主题)

enter image description here

在此处输入图片说明