使用Eclipse打包Android项目成Jar包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Greathfs/article/details/53013013

前言

今天在开发项目的时候遇到要求将java工程打包成可运行的jar的需求,上网找了找,也试了试,有两种办法可行,就把方法分享给大家

实现

  • 第一种 就是用Eclipse自带的功能就行(要打包的工程部没有第三方jar包)

    1. 工程中不包含第三方的jar包

第一步:选中我们要打包的工程,右键,—>选择Export
第二步:选中java— > JAR file,

            选中 Export generated class files and resources; 
            选中 Compress the contents of the JAR file; 
            选中 Overwrite existing files without warning;

第三步:然后“Next”

选中 Export class files with compile errors; 
选中 Export class files with compile warnings;

第四步:点击“Next”

选择“Main class”,然后点“finish” 即可。

运行jar包的方法:
cmd,进入jar包所在的位置,运行命令 java -jar *.jar,就可以了。或者直接配置文件关联。

  • 第二种 使用插件(工程包含第三方的jar包)
    安装步骤:

    Help > Install New Software > Add,
    name:Fat Jar
    location:http://kurucz-grafika.de/fatjar

第一步:右键 选择这个
这里写图片描述

第二部:
这里写图片描述

第三步:
这里写图片描述

结束

参考:
http://www.cnblogs.com/lanxuezaipiao/p/3291641.html

猜你喜欢

转载自blog.csdn.net/Greathfs/article/details/53013013