简体   繁体   中英

how to create a not runnable/not executable jar with other external jar dependencies in Eclipse

我无法通过eclipse导出向导创建普通的jar(不可运行/不可执行),它只创建jar文件,但是从某些其他类调用导出的jar的方法时,不会导出依赖的jar导致错误,请帮忙

Thanks a lot @kurellajunior for your suggestion .. it's solved by using the zipgroupfileset . below is the ant script which perfectly creates the jar as I needed

<project default="jar">
    <target name="jar">
            <jar destfile="destination directory/jarFileName.jar" basedir="my Eclipse project folder/bin (which holds all the .class files of my project separated by different package folder) ">
            <zipgroupfileset dir="Location of my external jar file directory" includes="*.jar"/>
            </jar>
        </target>
    </project>

This is intended in the language/IDE concept. You only create the jar (library). Dependencies are managed outside (like in maven) Executable jars can have a Manifest that points to the dependencies, but still the dependencies need to be bundled by you...

Netbeans in earlier time did a decent job in bundling all referenced jars together - haven't used it for a long time though.

Jan

EDIT: There is an option to create such a jar - on commandline. As jar is just a zip container, you can easily write a script, that unjars all your dependencies together with your jar in one place and then jar it all again together.

I do not recommend this!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM