Java

Installation

Best resource I've found is How to install Java JDK on macOS.

Latest version

brew install openjdk

As stated in the instructions printed by brew info openjdk, run:

sudo ln -svfn \
     $(brew --prefix)/opt/openjdk/libexec/openjdk.jdk \
     /Library/Java/JavaVirtualMachines/openjdk.jdk

Older versions

Older java packages may not work on Apple Silicon.

brew install openjdk@17
sudo ln -svfn \
     $(brew --prefix)/opt/openjdk@17/libexec/openjdk.jdk \
     /Library/Java/JavaVirtualMachines/openjdk-17.jdk

Switch Versions

To see installed Java versions (assuming they have been properly symlinked):

env

Note that java_home -V writes the "verbose" part of this output to stderr, and only writes the current version to stdout.

/usr/libexec/java_home -V

The java's installed via brew:

ls $(brew --prefix)/Cellar | grep openjdk
/usr/libexec/java_home -v 17

You can set JAVA_HOME to be one of those paths like this:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

GraalVM

Installation

query {
  repository(name: "graalvm-ce-builds", owner: "graalvm") {
    releases(orderBy: {field: CREATED_AT, direction: ASC}, last: 1) {
      nodes {
        name
        releaseAssets(first: 100) {
          nodes {
            name
            downloadUrl
          }
        }
      }
    }
  }
}
(require '[babashka.curl :as curl])

(def token (System/getenv "GITHUB_TOKEN"))

(def resp
  (curl/post
   "https://api.github.com/graphql"
   {:headers {"Authorization"
              (str "bearer " token)}
    :body (json/generate-string {:query q})}))

(def names-and-urls
  (-> resp
     :body
     (json/parse-string true)
     (get-in [:data :repository :releases :nodes])
     first ;; todo: map
     (get-in [:releaseAssets :nodes])))

;; Can there be multiple release assets with the same name?
(def my-items
  (filter ;; should this be a reduce?
   #(=
     "graalvm-ce-java17-darwin-amd64-22.1.0.tar.gz"
     (:name %))
   names-and-urls))

(-> my-item
    first
    :downloadUrl)

foo

#+RESULTS:
"https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java17-darwin-amd64-22.1.0.tar.gz"