Getting Alloy to run on Fedora Linux

Sharing the steps I took to get Alloy running on Fedora Linux in case anyone else has problems.

Problem

I am running Fedora 37 and have Java 8 installed, which I verified with java -version after activating that version following these instructions using sudo alternative --config java

If I install the Visual Studio Code extension for Alloy, I am able to run a spec, but the visualizer does not open when I click “Instance found. Predicate is consistent.”

When I download the .jar from GitHub and try to run it, I get the error (long stack-trace omitted):

Exception: java.awt.HeadlessException thrown from the UncaughtExceptionHandler in thread "AWT-EventQueue-0"

When I try to build the program from source, I get the error:

sean@carbon75 ~/s/org.alloytools.alloy (master)> ./gradlew build         (py39) 
Downloading https://services.gradle.org/distributions/gradle-7.2-bin.zip
..........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%

Welcome to Gradle 7.2!

Here are the highlights of this release:
 - Toolchain support for Scala
 - More cache hits when Java source files have platform-specific line endings
 - More resilient remote HTTP build cache behavior

For more details see https://docs.gradle.org/7.2/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :org.alloytools.api:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':org.alloytools.api:compileJava'.
> Could not find tools.jar. Please check that /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b09-2.fc37.x86_64/jre contains a valid JDK installation.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
2 actionable tasks: 2 executed

Solution

Although I was able to run java -version to confirm Java 1.8 was installed, my installation was actually broken. Reinstalling it with sudo dnf install java-1.8.0-openjdk allowed me to run the .jar. This also allowed me to get visualizations from the Visual Studio Code Alloy extension.