views:

3553

answers:

4

I am trying to sign a jar file using an ANT script. I know this has to be pointed at the JDK directory for jarsigner.exe to run, but when I echo java.home it returns the JRE directory.

This isnt a problem for javac because I can set the executeable path, but that does not exist for signjar.

How do I change the java.home path? When I right-click on MyComputer and go to

Properties > Acvanced > Environment Variables the "PATH" variable is correctly pointed to the JDK (C:\program files\java\jdk\bin).

Any help would be appreciated. Thanks.

UPDATE: The file now signs correctly after changing the PATH variable suggested below.

+2  A: 

Under Windows you need to follow:

Start -> Control Panel -> System -> Advanced -> Environment Variables.

... and you need to set JAVA_HOME (which is distinct from the PATH variable you mention) to reference the JDK home directory, not the bin sub-directory; e.g. "C:\program files\java\jdk".

Adamski
Changing that variable made it so the script doesnt crash so thank you there. Update above - SF and DSA files are not being placed in the JAR
Ken
A: 

Also be sure to set your JAVA_HOME environment variable. In fact, I usually set the JAVA_HOME, then prepend the string "%JAVA_HOME%\bin" to the system's PATH environment variable so that if Java ever gets upgraded or changed, only the JAVA_HOME variable will need to be changed.

And make sure that you close any command prompt windows or open applications that may read your environment variables, as changes to environment variables are normally not noticed until an application is re-launched.

Adam Batkin
Thanks the file does sign now, but under the META-INF folder I do not get a SF or DSA file that I get when I manually sign the jar. WebStart still says unsigned entries. Anything special I have to do for those to appear or are those needed?
Ken