bmaddy
bmaddy

Reputation: 895

How do I get the Dock icon to appear for a Clojure app on a mac?

Currently nothing (not even the java coffee cup) appears.

I created my app using lein new reagent name and I've tried these jvm options:

java -Xdock:name=Name
     -Xdock:icon=/Users/bmaddy/Downloads/logo.jpg
     -Dapple.awt.UIElement=true
     -Djava.awt.headless=false
     -jar name.jar

Upvotes: 1

Views: 105

Answers (2)

bmaddy
bmaddy

Reputation: 895

It turns out that just using Seesaw does something that makes the dock icon appear. That's good enough for what I need.

(ns name.server
  (:use seesaw.core)

Other stuff I tried:

The automator method described here only gave an icon to start the app and it didn't stick around while it was running: https://discussions.apple.com/thread/4805123

There's some good ideas here, but I wasn't able to get any of them to work: https://apple.stackexchange.com/questions/191609/how-to-create-a-app-folder-from-an-executable-jar

Building an .app package from scratch led to a bunch of LSOpenURLsWithRole() failed with error -10810 errors I wasn't able to solve, but that seems like it would be the most correct way to do it.

Upvotes: 0

nha
nha

Reputation: 18005

Why not use Java interop ? Following this SO post question :

// let's translate this
import com.apple.eawt.Application;
...
Application application = Application.getApplication();
Image image = Toolkit.getDefaultToolkit().getImage("icon.png");
application.setDockIconImage(image);

// into Clojure
(import com.apple.eawt.Application java.awt.Toolkit)
(let [app (Application/getApplication)
      image (.getImage (Toolkit/getDefaultToolkit) "icon.png")]
   (.setDockIconImage app image)))

Upvotes: 1

Related Questions