0

I am installing Alloy Model Checker (https://github.com/AlloyTools/org.alloytools.alloy). I cannot run gradlew build.

$ C:\Alloy\org.alloytools.alloy>gradlew build
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_172\bin;C:\Program Files\Java\jdk1.8.0_172;C:\Alloy\org.alloytools.alloy;C:\Program Files\Java;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

The ReadMe file:

 $ java version           # requires 1.8 (and NOT 1.9, gradle does not run on 1.9)
 java version "1.8.0_144"
 Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
 Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed model
 $ git clone https://github.com/AlloyTools/org.alloytools.alloy.git
 $ cd org.alloytools.alloy
 $ ./gradlew build
 $ java -jar org.alloytools.alloy.dist/target/org.alloytools.alloy.dist.jar
 # opens GUI
Griselle Z
  • 127
  • 1
  • 9
  • JAVA_HOME should be set as `C:\Program Files\Java\jdk1.8.0_172` omit `\bin` from end of that. look at this https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7 – Tashkhisi Jul 26 '20 at 14:46
  • I added both as ```C:\Program Files\Java\jdk1.8.0_172``` didn't work. – Griselle Z Jul 26 '20 at 15:39
  • What is the output for echo $JAVA_HOME? – Tashkhisi Jul 26 '20 at 15:45
  • I deleted ```\bin```, so ```echo %JAVA_HOME%``` now prints: ```C:\Program Files\Java\jdk1.8.0_172;C:\Alloy\org.alloytools.alloy;C:\Program Files\Java;``` I am using Windows 10. – Griselle Z Jul 26 '20 at 17:59
  • It is wrong your JAVA_HOME should be just C:\Program Files\Java\jdk1.8.0_172. set it again. – Tashkhisi Jul 26 '20 at 18:20
  • Read this https://www.google.com/amp/s/javatutorial.net/set-java-home-windows-10/amp – Tashkhisi Jul 26 '20 at 19:30
  • As noted, JAVA_HOME should be just one directory, not a list of directories. Also, some programs struggle with spaces - possibly try reinstalling Java outside of `Program Files`, or use the DOS path (C:\PROGRA~1 or similar) if absolutely necessary. –  Jul 26 '20 at 19:45
  • Hi, I have it in path C:\Alloy. I changed it so the output of ``echo %JAVA_HOME%``` is to ```C:\Program Files\Java\jdk1.8.0_172;```. But still ```gradlew build``` saying: ```ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_172; Please set the JAVA_HOME variable in your environment to match the location of your Java installation.``` – Griselle Z Jul 26 '20 at 19:48

1 Answers1

0
  1. So, the first thing that was wrong is that I tried to add more paths into JAVA_HOME and only one can be written.
  2. The second, I didn't delete ";" after deleting all JAVA_HOME paths. So JAVA_HOME is C:\Program Files\Java\jdk1.8.0_172 not C:\Program Files\Java\jdk1.8.0_172; (you need to enter the environmental variable, edit and "edit with text". Then delete the ";" at the end)
  3. The third was to add %PATH_HOME%\bin into the environmental variable Path. It was spoted by tashkhisi in the link: http://www.google.com/amp/s/javatutorial.net/set-java-home-windows-10/amp (thank you!).
Griselle Z
  • 127
  • 1
  • 9