How to generate a jar through ANT?

Asked

Viewed 472 times

0

I’m using Jdeveloper in conjunction with Ant, however I came across a very boring situation... I can’t generate one. functional jar through ant.

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

"cannot load or find main class"

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

What if I have another project as a dependency of my main project? This should be pointed out in the build/xml or manifest?

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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.