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

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 run. If it's a console application, you must open command line and type java minus jar and jar filename.

for instance, my file is configure as below:

1 Manifest-Version: 1.0

2 Class-Path: .

3 Main-Class: Deleter

 

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.

 

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

你可能感兴趣的:(eclipse)