• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
David Lambert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
vishu. gautam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael and welcome to Javaranch, also, thanks for sharing your answer!!
 
Rudolf Bohrer
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic