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 musttest run your
application in Eclipse. This will create a run configuration,
which we‘lluse later.I
have here two applications.One
is a consoleapplication 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
fileand
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
agui
application, you can click on jar file and it will run.If 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.
原文:http://www.cnblogs.com/listened/p/3525372.html