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 re
Simply, to enforce JAVA version to Ant in Eclipse:
Use RunAs option on Ant file then select External Tool Configuration in JRE tab define your JDK/JRE version you want to use.
Spent a few hours facing this issue this morning. I am likely to be the least technical person on these forums. Like the requester, I endured every reminder to set %JAVA_HOME%, biting my tongue each time I saw this non luminary advice. Finally I pondered whether my laptop's JRE was versions ahead of my JDK (as JREs are regularly updated automatically) and I installed the latest JDK. The difference was minor, emanating from a matter of weeks of different versions. I started with this error on jdk v 1.0865. The JRE was 1.0866. After installation, I had jdk v1.0874 and the equivalent JRE. At that point, I directed the Eclipse JRE to focus on my JDK and all was well. My println of java.home even reflected the correct JRE.
So much feedback repeated the wrong responses. I would strongly request that people read the feedback from others to avoid useless redundancy. Take care all, SG
For me, ant apparently refuses to listen to any configuration for eclipse default, project JDK, and the suggestion of "Ant Home Entries" just didn't have traction - there was nothing there referring to JDK.
However, this works:
Menu "Run" -> "External Tools" -> "External Tools Configuration".
Goto the node "Ant build", choose the ant buildfile in question.
Choose tab "JRE".
Select e.g. "Run in same JRE as workspace", or whatever you want.
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.