如何制作一个单一的jar.file文件? [英] How to make a monolithic jar.file?

查看:89
本文介绍了如何制作一个单一的jar.file文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个使用mahout和一堆其他库的hadoop作业jar文件。我需要能够在不需要额外jar.files的情况下运行作业,以便所有引用的类都与生成的jar文件打包在一起。如何做到这一点?

I need to create a hadoop job jar file that uses mahout and a bunch of other libraries. I need ti be able to run the job without needing additional jar.files such that all referenced classes are packaged with the resultant jar file. How can this be done?

推荐答案

配置您的构建文件以将所有引用的类复制到构建目录。例如,在 ant 中:

Configure your build file to copy all the referenced classes to the build directory. For example, in ant:

    <path id="classpathunjar">
        <fileset dir="${lib.dir}" includes="*.jar" excludes="sqljdbc4.jar"/>
    </path>


    <target name="compile" depends="clean">
        ...
        <unjar dest="${build.dir}">
            <path refid="classpathunjar" />
        </unjar>
        ...
   </target>

但是,如果您可以不进行管理就更好。使用 libjars 功能将jar加载到所有节点,如果您在hadoop集群上运行mapreduce作业

But it is better if you can manage without doing this. Use the libjars feature to load the jars into all nodes if you are doing this for running mapreduce jobs on a hadoop cluster

这篇关于如何制作一个单一的jar.file文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆