-4

My jar will not run after I compiled it. I use this ant build script

<project name="HelloWorld" basedir="." default="jar">

<property name="src.dir"     value="src"/>

<property name="build.dir"   value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir"     value="${build.dir}/jar"/>
<property name="libsSrc" value="libs"/>

<property name="main-class"  value="nat.ise.ApplicationStarter"/>

<path id="classpath">
    <fileset dir="${libsSrc}" includes="*.jar"/>
</path>

<pathconvert property="mf.classpath" pathsep=" ">
    <path refid="classpath"/>
    <mapper>
        <chainedmapper>
            <flattenmapper/>
            <globmapper from="*.jar" to="lib/*.jar"/>
        </chainedmapper>
    </mapper>
</pathconvert>

<target name="clean">
    <delete dir="${build.dir}"/>
</target>

<target name="compile">
    <mkdir dir="${classes.dir}"/>
    <javac srcdir="."  classpathref="classpath"  destdir="${classes.dir}"/>
</target>

<target name="jar" depends="compile">
    <mkdir dir="${jar.dir}"/>
    <jar destfile="${jar.dir}/${ant.project.name}.jar">
        <zipgroupfileset dir="${libsSrc}" includes="*.jar"/>
        <fileset dir="${classes.dir}" includes="**/*.class"/>
        <manifest>
            <attribute name="Main-Class" value="${main-class}"/>
            <attribute name="Class-Path" value="${mf.classpath}"/>
        </manifest>
    </jar>
</target>

</project>

The manifest is correct and I am managing to get some of the libraries included but when running from the cmd prompt i get the error

java.io.FileNotFoundException

The file it is referring to a JOGL library gluegen-rt-natives-windowsamd64.jar

Initially I was running the project from eclipse using the 32bit libraries, I have now included the 64bit libraries in the folder libs but it is still telling me that it cannot find them.

In fact I now can see, when I open the jar, two copies of all the .dll files (I can only assume that this is one from the 32bit and one from the 64bit versions of JOGL)

Is there not a way to make the program run using just the 32bit libraries? I want to reduce the ammount of distributions I have to make.

Neilos
  • 2,696
  • 4
  • 25
  • 51

1 Answers1

0

I don't think I deserved the downvotes but hey.

Well anyway the problem was that I was referencing .jars within .jars, I didn't think that this would be a problem but it was. The solution was to put the .jars (libraries) alongside my compiled application .jar and update the manifest accordingly. it is also possible to use .jars within .jars but you will need the use of another set of classes to let you do this. Eclipse has this and if you build excecutable .jar from within eclipse you can have .jars within .jars.

Neilos
  • 2,696
  • 4
  • 25
  • 51