aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes signjar with ant from eclipse -  BUILD FAILED: java.io.IOException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "signjar with ant from eclipse -  BUILD FAILED: java.io.IOException" Watch "signjar with ant from eclipse -  BUILD FAILED: java.io.IOException" New topic
Author

signjar with ant from eclipse - BUILD FAILED: java.io.IOException

David Lambert
Greenhorn

Joined: Mar 24, 2003
Posts: 4
Hello,
I' m having a problem signing a jar with ant.
While the target works if run from the command line, when I run it from eclipse I get the following error:
[signjar] BUILD FAILED: file:C:/MyPath/build.xml:358: Execute failed: java.io.IOException: CreateProcess: jarsigner -keystore C:\storepath -storepass mypassword -keypass mykeypass -signedjar C:\signedjar.jar C:\myjar.jar myalias error=2
This is what I have in build.xml:
<signjar alias="myalias" jar="${app.name}.jar" keypass="mykeypass" keystore="${build.home}/storepath" signedjar="${build.home}/sgn${app.name}.jar" storepass="mypassword"/>
The paths and variables look fine (it works from command line...) so I don' t really know what' s wrong...
Thanks for any help!
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

It seems to me that Ant can't find the jarsigner executable. I'd guess that means the JAVA_HOME/bin is not in the path, but you say it works from the command line. Maybe Eclipse adjusts the path to make sure a particular JDK is being used?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

I really don't think it's a classpath problem, but rather your regular path, that thing that tells the system where to look for executables. I don't know why Eclipse would use a different one from the command line though. Just for fun, try copying the jarsigner.exe from JAVA_HOME/bin to another directory in your path, e.g., c:/winnt/system32 If that works, you know Eclipse is definitely messing with your path.
David Lambert
Greenhorn

Joined: Mar 24, 2003
Posts: 4
Hi Greg, thanks a lot for your time!
You are absolutely right. After checking the 'Path' variable, it turns out I didn' t have
'%JAVA_HOME%\bin' in it.
Everything works fine now.
Still don' t understand why I could use the command line to run signjar or ant tasks though...trying to find that out now.
Thanks a lot again. That was great help!
David Lambert
Greenhorn

Joined: Mar 24, 2003
Posts: 4
My previous message got deleted by mistake while I was trying to edit it earlier...so I post it again just in case there is someone else with the same problem...
>Hi Greg, thanks for your reply.
>
>In my environments variables I have:
>JAVA_HOME = C:\j2sdk1.4.1_01
>ANT_HOME = C:\ant-1.5
>
>In Eclipse Window > Preferences > Ant > >Runtime
>ANT_HOME = C:\ant-1.5
>(which sets my runtime classpath to:
> C:\ant-1.5\lib\ant.jar
> C:\ant-1.5\lib\catalina-ant.jar
> C:\ant-1.5\lib\optional.jar
> C:\ant-1.5\lib\xml-apis.jar
> To this I' ve added:
> C:\j2sdk1.4.1_01\lib\tools.jar
> I' ve tried adding
> C:\j2sdk1.4.1_01\bin
> but no luck...
>
>
>In Eclipse Window > Preferences > Java >> Installed JREs:
>C:\j2sdk1.4.1_01
>
>I really cannot see what is wron
>
Kunal Changela
Greenhorn

Joined: Sep 16, 2004
Posts: 1
I had exactly the same problem with the jarsigner.exe

I have fixed the problem but you will be very surprised as to how I have done so. ALL I did was:

1) remove all the installed JREs from the Window -> Preferences -> Java -> Installed JREs

2) add a JRE with the path to my root J2SDK folder (JRE home directory: C:\j2sdk1.4.2_05) with the (JRE name: j2re1.4.2_05).

3) i had NO environment variables, system variable set to point to any Java bins, libraries etc.

4) there was also no need to add tools.jar to my ANT runtime classpath entries.

My jar signing, compiling and building ALL works.

Hope this is useful.
[ September 16, 2004: Message edited by: Kunal Changela ]

Kunal D Changela
vishu. gautam
Greenhorn

Joined: Dec 18, 2004
Posts: 1
I was getting the same problem as listed above and fixed it as mentioned in the replies. Now I have a another problem.

The jarsigner tasks works well sometimes. At other times it fails with error message suggesting that it failed to rename the original ...jar file to same ...jar.os.. file.
However, When I run the ant script again it works fine, successfully signing the jars.

So this is kind of a error which occurs intermittently.

Any pointers anyone?
eleele ele
Greenhorn

Joined: Jul 09, 2010
Posts: 1
Hi!
I had the same problem and I solved it executing eclipse in the windows console with this command ">eclipse.exe -vm "C:\Archivos de program
a\Java\jdk1.5.0_18\jre\bin\javaw.exe"


Hope this helps!!
Michael Gofman
Greenhorn

Joined: Nov 03, 2010
Posts: 2
Just ran into the same problem.
Spent quite a bit of time searching for a solution. Finally figured it out. This should have been obvious, but should have been configured by default.
The problem is that Ant needs to use the jarsigner from JDK , not JRE "jarsigner" utility is not a part of a JRE.
Navigate to :
Right click on your XML file that you generated in Eclipse-> Run As -> External Tools Configuration...
Select the JRE tab , click the Installed JREs... button.
Then select an installed JDK not a JRE.
Everything will then compile and sign successfully.

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Michael and welcome to Javaranch, also, thanks for sharing your answer!!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Rudolf Bohrer
Greenhorn

Joined: Feb 02, 2012
Posts: 1
Michael Gofman wrote:Just ran into the same problem.
Spent quite a bit of time searching for a solution. Finally figured it out. This should have been obvious, but should have been configured by default.
The problem is that Ant needs to use the jarsigner from JDK , not JRE "jarsigner" utility is not a part of a JRE.
Navigate to :
Right click on your XML file that you generated in Eclipse-> Run As -> External Tools Configuration...
Select the JRE tab , click the Installed JREs... button.
Then select an installed JDK not a JRE.
Everything will then compile and sign successfully.


Thanks, that helped, fast and easy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: signjar with ant from eclipse - BUILD FAILED: java.io.IOException