如何在IDE之外运行Java Swing应用程序 [英] How to run Java Swing Application outside IDE

查看:460
本文介绍了如何在IDE之外运行Java Swing应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有一些GUI组件和一些java代码的小型swing应用程序。当我从IDE运行它,我看到GUI打开,它的工作原理。现在我想将此应用程序分发给其他人,它将在不同的机器上运行。我只是想知道如何分发它?



在项目文件夹下,我看到以下 -

  -dist 
--lib
----一些需要的jar文件
--project.jar

-build
--classes
---- packagename文件夹 - > UI类
---- projectnamefolder ---> projectname.class
--empty
- -generated-sources

我正在使用Windows 7 64位与jdk 1.7。早些时候,我能够分发这样的应用程序,他们通过命令行或双击.jar文件工作。



在swing应用程序中有什么不同吗?如果我从命令提示符运行位于dist文件夹下面的jar文件,它不会出现任何错误,但是没有出现GUI。



解决方案

请按照 LINK 和其他系统将需要JRE运行。



我想你缺少 swing-layout-1.0.jar



要添加Swing布局扩展库:



右键单击项目的库节点,然后选择添加库。



在添加库对话框中,选择Swing扩展布局,然后单击添加库。



单击确定关闭项目属性对话框。






除了执行Shiv建议之外,我遵循链接,它点击我,因为我做错了。


I created a small swing application having some GUI components and some java code. When I run it from the IDE, I see GUI open and it works as expected. Now I want to distribute this application to others and it will be run on different machines. I am just wondering as how could I distribute it?

Under project folder, I see following -

-dist
--lib
----some required jar files
--project.jar

-build
--classes
----packagename folder -->UI classes
----projectnamefolder--->projectname.class
--empty
--generated-sources

I am using Windows 7 64 bit with jdk 1.7. Earlier I was able to distribute such apps and they worked from command line or by double clicking .jar file.

Is there anything different in case of swing apps? Kindly suggest.

If I run from command prompt the jar file located under dist folder, it doesn't throw any error but no GUI appears.

解决方案

Follow these Steps in LINK and other system will need JRE to run.

I think you are missing swing-layout-1.0.jar

To add the Swing Layout Extensions library:

Right-click the project's Libraries node and choose Add Library.

In the Add Library dialog box, select Swing Extensions Layout and click Add Library.

Click OK to close the Project Properties dialog box.


Additional to doing what Shiv suggested, I followed link , and it clicked to me as what was i doing wrong.

这篇关于如何在IDE之外运行Java Swing应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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