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 23:46:15 GMT
Here are two possible workarounds:

If your image is in
<jar>/images/img.gif
you can load it with getClass().getResource("/images/img.gif")

Or, if the class that loads the images is in the org.somebody package,
and the image is in
<jar>/org/somebody/img.gif
you can load it with getClass().getResource("img.gif")

Take a look at the Class.getResource javadoc if this doesn't seem correct.




Duffey, Kevin wrote:

>Haha, that is exactly what I was trying to avoid, wrapper script. In my code, since I
know it is deployed in a .jar file, I have the getClass().getClassLoader().getResource("relative-path/img.gif");
for example, so using the wrapper class would work from a batch file, but the other way I
tried is using the classname approach in <java task, and that didn't work because the above
code looks for resources within the jar and since it wasn't running in a .jar, it wouldn't
work. Man, I can't believe there is no other way around this!
>
>
>-----Original Message-----
>From: __matthewHawthorne [mailto:mhawthorne@alumni.pitt.edu] 
>Sent: Wednesday, July 23, 2003 4:38 PM
>To: Ant Users List
>Subject: Re: Problem running executable jar - classpath issues
>
>This is default jar file behavior, and AFAIK, there is no way to change 
>it.  If it is a huge problem, a problem large enough to make you want to 
>question your deployment strategy, you may want to either try using 
>links (if you're using unix), or creating a wrapper script to set your 
>classpath and run your program.
>
>
>
>
>Duffey, Kevin wrote:
>
>  
>
>>Ok, that sucks then. So, when deploying, my executable .jar is wrapped up in a zip
file along with the lib dir. Unzipped the lib dir and app.jar are in the same dir. Therefore,
relative of lib/xxx would work in that case. When developing, I don't want to put the normal
<root>/lib in the <dist> dir as well, that is wasted space, not that it’s a
big deal, but it looks bad and requires extra maintenance. I can't believe there is no way
to have Ant execute a jar file in such a manner as to indicate that the .jar file is being
ran from another dir. I thought that is what the dir="" in the <java > call was for,
to tell it where to start the JVM from, and thus if it loads the executable .jar file from
some sub-dir, it would force it to operate out of the location dir="" is set to. Is there
anything like that, or any other way to do this?
>>
>>
>>-----Original Message-----
>>From: Conor MacNeill [mailto:conor@cortexebusiness.com.au] 
>>Sent: Wednesday, July 23, 2003 4:31 PM
>>To: Ant Users List
>>Subject: Re: Problem running executable jar - classpath issues
>>
>>On Thu, 24 Jul 2003 08:35 am, Duffey, Kevin wrote:
>> 
>>
>>    
>>
>>>Hi all,
>>>
>>>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.
>>    
>>
>>>   
>>>
>>>      
>>>
>>Classpath entries in a manifest are relative to the location of the jar, not 
>>    
>>
>>from where you are running the code.
>  
>
>>Conor
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>---
>>Incoming 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
>>
>>
>>---
>>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
>
>
>---
>Incoming 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
> 
>
>---
>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
> 
>
>---------------------------------------------------------------------
>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