Some things to check or consider if you want to run from a JAR file:
1) Does your manifest.mf file exist in the /meta-inf directory?
2) Does your manifest.mf file contain the entry "Main-Class:
full.path.and.class.Name" ?
3) Try using <arg line="-jar jarfilename" />
4) To my knowledge, passing in the classname attribute to the Java task
won't help you
if you are using the -jar option.
Good luck,
- Jeff Davies
Silicon Valley (aka Ferrari land, aka I can't afford to live here), USA
-----Original Message-----
From: Alain RAVET [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 23, 2001 9:11 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: launch an application stored in a jar
Hi,
I cannot make Ant launch a class that is stored in a jar file.
I tried many variants, but to no avail.
Thanks in advance
Alain RAVET
Brussels, Belgium
The original version where I lauch the class directly (not from a jar) works
fine :
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - run -->
<property name="entry.point.class"
value="cirb.teletest.project.JJJYNet.Test_project_p_JJJYNetDB" />
<target name="run" depends="compile">
<java classname="${entry.point.class}" fork="yes"
failonerror="true"
dir="data">
<classpath refid="libraries.path" />
<classpath path="${build.dir}" />
<arg value="conf.log4j" />
</java>
</target>
--------------------------------------------------
I use the following manifest file :
MANIFEST.MF file contents (2 lines):
---
Manifest-Version: 1.0
Main-Class: cirb.teletest.project.JJJYNet.Test_project_p_JJJYNetDB
---
The following attempt does not work :
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - runFromJar -->
<target name="runFromJar" depends="compile">
<java classname="${entry.point.class}" failonerror="true"
dir="data">
<arg value="-jar ${local.CirbJarfile}" />
<classpath refid="libraries.path" />
<classpath >
<pathelement location="${local.CastorJarfile}" />
<pathelement location="${local.CirbJarfile}" />
</classpath >
<arg value="conf.log4j" />
</java>
</target>
==> Error message :
Démarrage de AntRunner ...
La cible est 'runFromJar'
Ant version 1.2 compiled on October 24 2000
Buildfile: D:\newcvs\p_JJJYNetDB\build.xml
Detected Java Version: 1.3
Detected OS: Windows NT
Project base dir set to: D:\newcvs\p_JJJYNetDB
Build sequence for target `runFromJar' is [init, compile,
runFromJar]
Complete build sequence is [init, compile, runFromJar,
makeCastorjar,
makeCirbjar, make2jars, run, document, FullMonthy]
[java] Forking java -classpath
D:\newcvs\p_JJJYNetDB\CastorPatched.jar;D:\newcvs\p_JJJYNetDB\p_JJJYNetDB.ja
r;M:\dev\libs\_allJars\log4j.jar;M:\dev\libs\_allJars\junitx-4.0b.jar;M:\dev
\libs\_allJars\jdbc-se2.0.jar;M:\dev\libs\_allJars\jta1.0.1.jar;M:\dev\libs\
_allJars\jtf-0.1.jar;M:\dev\libs\_allJars\ldapjdk.jar;M:\dev\libs\_allJars\l
dapsp.jar;M:\dev\libs\_allJars\mm.mysql-2.0.3.jar;M:\dev\libs\_allJars\sax2.
jar;M:\dev\libs\_allJars\xerces.jar;M:\dev\libs\_allJars\xslp.jar;M:\dev\lib
s\_allJars\jakarta-regexp-1.1.jar;D:\newcvs\p_JJJYNetDB\src
cirb.teletest.project.JJJYNet.Test_project_p_JJJYNetDB "-jar
p_JJJYNetDB.jar" conf.log4j
[java] java.lang.NoClassDefFoundError:
cirb/teletest/project/JJJYNet/Test_project_p_JJJYNetDB
BUILD FAILED
D:\newcvs\p_JJJYNetDB\build.xml:98: Java returned: 1
--------------------------------------------------
In the build.xml file, I create the jar
<target name="makeCirbjar" depends="compile">
<delete file="${local.CirbJarfile}" />
<jar jarfile="${local.CirbJarfile}"
manifest="./src/META-INF/MANIFEST.MF"
>
<!-- exclude the Test classes *.class for the jar -->
<fileset dir ="${build.dir}" includes="cirb/"
excludes="**/Test*.class" />
</jar>
</target>
When I check the contents of the jar, I can see the manifest is there.
--------------------------------------------------