How to run Java Swing Application outside IDE

2019-08-08 02:16发布

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.

enter image description here

2条回答
萌系小妹纸
2楼-- · 2019-08-08 02:17

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?

For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.

..sounds cool, would search some tutorials as to see how to use it

The info. page at SO linked above includes the collected knowledge of the SO poster who has the most up-votes for JWS ( me ;) ). It also includes a list of links to tutorials and other information.

查看更多
别忘想泡老子
3楼-- · 2019-08-08 02:36

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.

查看更多
登录 后发表回答