Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of double-clickable .sh and .bat on Mac?

Tags:

I am distributing a Java program where I want a double-clickable file to run

java -cp MyProgram.jar;MyLib.jar my.program.Main 

On Windows I simply distribute a .bat file, for *nix an executable .sh file. Problem is, double-clicking the .sh file just opens it up in a text editor on Mac. What should I do for Mac?

like image 681
Epaga Avatar asked Feb 26 '09 10:02

Epaga


People also ask

What is the .bat equivalent for Mac?

Info from some answers after the question: BAT file was an attempt to bring to MS-DOS something like the idea of the UNIX script. the text file as executable (rather than give it a specific suffix). This is how OS X does it.

How do I double click script on Mac?

macOS - How to execute a shell script with a double clickMost of use use the extension ". sh" for a shell script, but this could be associated with a text editor like BBEdit (highly recommended and there is a free version). So instead of running the script, it will open it in your text editor.

How do I run a .bat file on Mac?

Easiest way for a lazy Mac user like me: Drag-and-drop the startup.sh file from the Finder to the Terminal window and press Return. To shutdown Tomcat, do the same with shutdown.sh . You can delete all the . bat files as they are only for a Windows PC, of no use on a Mac to other Unix computer.

Can you run a .sh file on Mac?

sh script on macOS. Shell scripts are normally written and run on Linux systems but they're almost as at home on a Mac system as they are on a Linux system. You can write a Shell script on macOS, and you can run it easily, far more easily than you can on a Windows 10 system.


2 Answers

On mac, there is a specific extension for executing shell scripts by double clicking them: this is .command.

like image 169
mouviciel Avatar answered Oct 12 '22 09:10

mouviciel


For Java applications on Mac, you really should use Apple's Jar Bundler (in the Developer Tools/Applications/Utilities folder; really a symlink to /usr/share/java/Tools/Jar Bundler). It lets you make a proper OS X double-clickable app, including setting preferences for e.g. using the Mac toolbar, JVM version, graphics system, OS X app metadata and classpath/resources.

like image 42
Barry Wark Avatar answered Oct 12 '22 11:10

Barry Wark