简体   繁体   English

在Eclipse中测试时,Eclipse Java窗口打开,但在导出时则不打开

[英]Eclipse Java window opens when testing in eclipse, but not when exported

So I have a Java window in Eclipse, and it has no errors or warnings. 所以我在Eclipse中有一个Java窗口,它没有错误或警告。 Here is that: 这是:

应用图片

It launches just fine when I run it in Eclipse, and I've exported programs before like this, but when I export it to a JAR file and run it, it loads for a split second and then no window appears (the application doesn't show up in the task manager either). 当我在Eclipse中运行它时,它可以很好地启动,并且我以前已经像这样导出过程序,但是当我将其导出到JAR文件并运行时,它会瞬间加载,然后没有窗口出现(应用程序没有t也显示在任务管理器中)。 Here's my settings for the build: 这是我的构建设置:

构建设置图像

It builds just fine, but when clicked, it doesn't open the window! 它的构建很好,但是单击时不会打开窗口! What am I doing wrong here? 我在这里做错了什么?

这只是一个猜测,但是您可能需要在启动时使用以下标志:-XstartOnFirstThread

According to the picture you added, you are not exporting your project as a runnable JAR file. 根据添加的图片,您没有将项目导出为可运行的JAR文件。 A runnable JAR includes the MANIFEST.MF, which defines the Main class to be executed when you run the JAR. 可运行的JAR包括MANIFEST.MF,它定义了运行JAR时要执行的Main类。

Right Click on project -> Export -> Java -> Runnable JAR file, on the next screen select your Main class and define export destination and check "Extract required libraries into generated JAR. 右键单击项目->导出-> Java->可运行的JAR文件,在下一个屏幕上选择您的Main类并定义导出目标,然后选中“将所需的库提取到生成的JAR中。

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

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