在eclipse中将java导出为可执行文件.

  Ref: http://java.chinaitlab.com/Eclipse/812775.html and http://www.javavids.com/video/how-to-create-an-executable-jar-file-in-eclipse.html

  Right now your project is bunch of java files in Eclipse. But usually when you finish your application, you want to create a runnable file, so that somebody else can execute it. How to do that?

  1)First you must test run your application in Eclipse. This will create a run configuration, which we'll use later.I have here two applications.One is a console application and the other is a gui application.To create a runnable file, you must 

  2)right click your project and 

  3)choose export. Choose 

  4)Runnable Jar file and 

  5)click next. There you must 

  6)choose your launch configuration, which is the same as run configuration created earlier.

  7)Type export destination jar file. And choose what to do with libraries, that your application use. I  

  8)usually choose to copy libraries into a subfolder. Click finish.Now we'll go to the output folder. Here you can run your application in two ways. 

  9)If your application is a gui application, you can click on jar file and it will runIf it's a console application, you must open command line and type java minus jar and jar filename.

for instance, my console app is export to my path"H:\OwnTool\RemoveFileToDirectory\Mover.jar",so my command prompt is :

  

1 java -jar H:\OwnTool\RemoveFileToDirectory\Mover.jar

  By the way, what is jar file anyway? It's an ordinary zip archive, where are packages with class files and META-INF directory with manifest mf file. In this file is mainly defined application classpath and a default main class to execute if you want to run this application.

posted @ 2014-01-18 19:00  wonkju  阅读(487)  评论(0编辑  收藏  举报