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 isn't a problem for javac, because I can set the executable 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 > Advanced > Environment Variables
The "PATH" variable is correctly pointed to the JDK (C:\program files\java\jdk\bin
).
Update: The file now signs correctly after changing the PATH variable suggested below.
In Eclipse the Ant java.home variable is not based on the Windows JAVA_HOME environment variable. Instead it is set to the home directory of the project's JRE.
To change the default JRE (e.g. change it to a JDK) you can go to Windows->Preferences... and choose Java->Installed JREs.
To change just a single project's JRE you can go to Project->Properties and choose Java Build Path and choose the Libraries tab. Find the JRE System Library and click it, then choose Edit and choose the JRE (or JDK) that you want.
If that doesn't work then when running the build file you can choose Run as->Ant Build... and click the JRE tab, choose separate JRE and specify the JRE you want there.