ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claudio Corsi <cco...@progress.com>
Subject Re: Problem running executable jar - classpath issues
Date Thu, 24 Jul 2003 17:22:42 GMT
Hi Kevin,

When I encounter such a problem, I would start out by removing ant from 
the picture.

Run the java command from the command and determine if it runs as expected.

If this works, I would recommend that you generate a production type 
distribution that you test using ant. Test and determine if this works 
or not.

The reason I recommend this is that I have had the misfortune to test 
something one way and have the production version expect a different 
environment. I would then get that dreaded email stating it does not 
work and feel like a fool :(.

If this does not work then you should run ant with the -debug option and 
  see what java command is really run.

--Claudio

Duffey, Kevin wrote:
> Hi all,
> 
> My project builds everything into an executable .jar file, except it doesn't embed 3rd
party .jar files it relies on because the JVM doesn't support finding classes in .jar files
embedded in the main executing jar file. So, I zip everything up, when unzipped it creates
a dir with the executable .jar file in the root, and a lib directory where it places all 3rd
party libraries.
> 
> My script is able to compile against it no problem:
> 
> 
> 	<path id="compile.classpath">
> 		<fileset dir="${lib.dir}">
> 			<include name="*.jar"/>
> 		</fileset>
> 	</path>
> 
> 	<path id="test.classpath">
> 		<path refid="compile.classpath"/>
> 		<pathelement location="${junit.jar}"/>
> 		<pathelement location="${test.dir}"/>
> 	</path>
> 
> 	<path id="run.classpath">
> 		<path refid="compile.classpath"/>
> 		<pathelement location="${build.dir}/classes"/>
> 	</path>
> 
> 
> The execute task:
> 
> 	<target name="execute">
> 		<java jar="${dist.dir}/app.jar" fork="true" failonerror="false">
> 			<classpath refid="run.classpath"/>
> 		</java>
> 	</target>
> 
> The problem is, I build the app.jar into my <project root>/dist/app.jar, and the
lib files are not being found when it executes. They are in <project root>/lib/*.jar
(also known as ${lib.dir}). If I copy the lib directory to my dist directory, it works. Internally,
my code uses relative paths to find property files in the app.jar. But in my main class I
use Log4J, which is specified in the manifest class-path as lib/log4j.jar. Thus, it is relative
to the location of the startup of app.jar. However, it appears even though I have followed
the Java Development with Ant book, it still can't find my lib/*.jar files.
> 
> So, I am guessing that even though my build script is in <project root> and it
starts the app.jar from within <project root>/dist/app.jar, it is seeing the root dir
as the <project root>/dist/ directory. If it wasn't, then the relative paths in Class-Path
in the manifest file would work. And that would explain why when I copy it to the dist dir,
it works.
> 
> Can somebody please explain how to make this work? I don't want to have to copy my app.jar
into the <project root> dir, nor do I want to keep two directories of the libraries!
I want to use my <project root>/lib/*.jar from the app.jar located in <project root>/dist/app.jar,
and execute this from the build script.
> 
> Thanks.
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003
>  
> 
> 
> ***************************************************************************
> "The information contained in this e-mail message  may be confidential and 
> protected from disclosure.  If you are not the intended recipient, any 
> dissemination, distribution or copying is strictly prohibited.  If you think 
> that you have received this e-mail message in error, please e-mail the 
> sender at exchangeadmins@marketron.com."
> ***************************************************************************
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message