8

I've downloaded jmeter and put it in my Applications folder.
I've made it executable.
I can cd to /Applications/apache-jmeter-2.11/bin and can run it in a terminal with

$ ./jmeter

or by double-clicking the icon from the finder.

How can I add the program as a shortcut (icon) on the main application icon launcher bar ('Dock') on a Mac, similar to programs such as browsers, MS Outlook, gitx, etc?

4 Answers 4

8

You can use AppleScript to make a .app file for this (That is the only file type that can go in the left side of the dock). It is in /Applications/Utilities/AppleScript Editor and when you make a new file you can put in do shell script "/Applications/apache-jmeter-2.11/bin/jmeter". I do this all the time for shell scripts, so I can access them easily. Then you can save and choose "app" near the bottom of the Save sheet. This will create an app file that you can put in, say, the folder above bin which can be dragged into the Dock.

tell app "Terminal"
    activate
    do script "/Applications/apache-jmeter-2.11/bin/jmeter"
end

is what you will need if jmeter writes to the terminal.

3
  • Is this just run from the terminal? IE, how would I execute these commands from within a programming language. What Runtime.exec command could I use?
    – dessalines
    Commented Jun 14, 2015 at 18:49
  • Now, this utility is called Script editor.
    – catch23
    Commented Jan 11, 2019 at 19:54
  • @0942v8653 how to run ApacheJMeter.jar instead of executing ./jmeter in terminal.
    – catch23
    Commented Jan 11, 2019 at 20:16
2

When you launch it does it show an icon in the dock? If not it may be a command line program that is running inside terminal. If that is the case there are ways to make an Applescript/Automator wrap-around that will launch command line applications that should give you a dock icon.

Having never done this myself, however, I am afraid you will have to do some googling, but hopefully this points you in the right direction.

1
  • +1 Yes it's run from a terminal with a ./, so yeah I would guess some sort of wrapper is needed. Commented Mar 24, 2014 at 18:03
2

Such binaries can't be added to the left side of the Dock where applications are stored.

Add it to the right side of the Dock instead

Right of the separator:

1
  • Why can't they be at left?
    – Pacerier
    Commented Dec 15, 2017 at 20:59
2

Somewhat copied from: Executing Shell Scripts from the OS X Dock

The following creates a running application that doesn't need to spawn the terminal to work. Do something like the following from the command line:

name='JMeter Launcher'
apppath='/Applications/apache-jmeter-2.11/bin/jmeter'
mkdir -p "/Applications/$name.app/Contents/MacOS"
cat > "/Applications/$name.app/Contents/MacOS/$name" <<EOF
#!/bin/sh
$apppath
EOF
chmod +x "/Applications/$name.app/Contents/MacOS/$name"

This will create a clickable application that when run will execute the shell script with the same name which will run your jmeter binary.

Notice that the JMeter Launcher name must match the .app top directory name and the script name down in MacOS directory precisely which is why this script stores it in a variable.

Also, if you want to change the icon, you can select the application in the Finder, get info about it, select the default icon at the top of the info window, and paste a 512×512 PNG image over it.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .