How to generate a jar through ANT?

0

I'm using Jdeveloper together with Ant, though I came across a pretty boring situation ... I can not generate a functional .jar through the ant.

I have already built a build.xml containing the path to main class, however ... whenever I try to run the jar that was generated, I get the message:

"can not load or find main class"

When we create a deploy profile in Jdeveloper, we build a kind of manifest, pointing to the main class and loading the other classes into it. I would like to know if it is necessary to generate this manifest before, and finally what items should I insert inside the manifest ... only my project classes?

What if I have another project as a dependency on my main project? Should this be pointed out in build / xml or manifest?

    
asked by anonymous 14.10.2015 / 23:00

1 answer

1
<property name="build.dir" value="/home/wender/" />
<property name="jar.name" value="meuQuerido.jar" />

<!-- Diretório onde sua IDE gera os .class -->
<property name="dir.compilacao.java" value="c:/No/Eclipse/fica/em/no/diretorioDoMeuWorkspace/MeuProjeto/bin" />

<jar destfile="${build.dir}${jar.name}">
    <manifest>
        <!-- Substitua org.minha.Main.class pela sua (caminho completo)-->
        <attribute name="Main-Class" value="org.minha.Main.class" />
    </manifest>
    <fileset dir="${dir.compilacao.java}"/>
        <include name="**/*.class" />
    </fileset>
</jar>
    
03.03.2016 / 21:33