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!
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?
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.
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!
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 >
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.