ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <mhawtho...@alumni.pitt.edu>
Subject Re: Problem running executable jar - classpath issues
Date Wed, 23 Jul 2003 22:54:33 GMT
I don't fully understand the details of your situation, but you might 
want to try using the "dir" attribute in the <java/> task.  It will 
allow you to invoke the JVM wherever you want, and then your executable 
jar may be able to find it's 3rd party jars.

Try <java dir=<your project root> ... />

I hope this helps...




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