Tin Man
Tin Man

Reputation: 878

How to package Java GUI apps for Homebrew

I'm trying to package a GUI app for homebrew, but I'm running into a problem.

I'm packaging with this installation script, as per the instructions at the Frankel.ch blog:

def install
    libexec.install Dir['*']
    bin.write_jar_script libexec/'FOSStriangulator.jar', 'fosstriangulator'
end

And I'm using depends_on "openjdk" as my dependency, as depends_on :java => '1.8+' recommended by the article doesn't work.

But when running this package, I get this error:

java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler

Is this because, rather than a library, my app is a GUI app?

In the terminal, running just via java -jar works fine for me.

Upvotes: 0

Views: 205

Answers (1)

fn control option
fn control option

Reputation: 1953

As others have stated, QuitHandler was removed, but if you absolutely must use JDK 8, you can try copying one of the homebrew/core formulae that requires it. For example, the digdag formula:

class Digdag < Formula
  url "https://dl.digdag.io/digdag-0.10.3.jar"
  sha256 "200911b6a35a3d8b40e25f028753fb9652aeb19dbd05b8f950dc35ff69547c34"

  depends_on arch: :x86_64 # openjdk@8 is not supported on ARM
  depends_on "openjdk@8"

  def install
    libexec.install "digdag-#{version}.jar"
    bin.write_jar_script libexec/"digdag-#{version}.jar", "digdag", java_version: "1.8"
  end
end

In your case, you probably want something like this:

class Fosstriangulator < Formula
  url "..."
  sha256 "..."

  depends_on arch: :x86_64 # openjdk@8 is not supported on ARM
  depends_on "openjdk@8"

  def install
    libexec.install Dir["*"]
    bin.write_jar_script libexec/"FOSStriangulator.jar", "fosstriangulator", java_version: "1.8"
  end
end
  • depends_on :java => '1.8+' is replaced by depends_on "openjdk@8"
  • The parameter java_version: "1.8" should be added to bin.write_jar_script

Upvotes: 1

Related Questions