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

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?

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

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.

You can use a .sh (Shell Script), after all MacOSX is Unix!

The answer about using the Jar Bundler tool is correct, but if you want to use a .sh file, make sure the unix permissions are set properly to something like 755 with CHMOD, and make sure the first line contains the path to a shell installed by default on Mac OS X. Also note that even with the +x bit set, it may still ask the user whether they want to open it or run it.

Related

How to launch exe from PyCharm Terminal?

I'm trying to launch Blender directly from PyCharm Terminal on Windows. I first use cd 'C:\Program Files\Blender Foundation\Blender 3.1\' to get into the directory containing the executable I need, and this works okay. Then I call blender.exe and expect it to launch Blender executable from the directory I am currently in. But for some reason it launches the older (2.93) version from another folder. The same steps work just right when I do all the same in the Windows cmd.exe. I've thought that the problem could be with the Python interpreter, but I use Python interpreter that goes with Blender 3.1 in the PyCharm project settings. What am I doing wrong and how can I run the exact executable I need?
P.S. I know that I can write a simple script in Python, use subprocess module, and get almost the same result, but anyway I'd like to use the launch from the Terminal if it is possible.

macos OS X equivalent of Linux .desktop file

I have developed a set of shell scripts that work on Windows and Linux and would like to distribute them for macos 10.4 and following. (They are to help language development workers in minority languages keep their software up-to-date. You can read about the project at lingtransoft LangTran.)
I make the Windows installer with Inno Setup and the .deb file for Linux with EPM. I have been able to make a .pkg installer by running EPM on a Mac, and it installs the shell scripts to the right place, and they work properly when I run them from a Terminal window, but I would like to provide clickable icons. If I can work out the macos/OS X equivalent of a Linux .desktop file, I should be able to get the EPM package maker to install the launcher files in the right place.
For Linux, EPM will package my hand-crafted .desktop files and install them in the right place for them to appear in the menu. (Here is one of the .desktop files:
[Desktop Entry]
Name=LangTranUpdate
X-GNOME-FullName=LangTran Update Script
GenericName=Software Distribution System updater
Comment=For updating a local software repository
Path=/usr/local/langtran
Exec=/usr/local/langtran/LangTranUpdate.sh
Icon=/usr/local/langtran/Progs/LangTran-icon.ico
Terminal=true
Type=Application
Categories=Network
StartupWMClass=gpodder
)
The script needs to run in the folder /usr/local/langtran because it looks for other files in the same place, so the "Path" key is set to that. The Windows shortcut files work the same way.
Since macos doesn't have a START button to open a menu tree, I would like the installer to put clickable objects on the desktop so the user can drag them to the Dock if desired.
So my question is: How do I make the macos/OSX equivalent of a Linux .desktop file or a Windows shortcut?

How create .app for mac osx from tcl script applicaton

I have anyProject.tcl script application. It working properly in MAC OSX from terminal using wish tclfileName.tcl. I want to create it like .app or some other way without terminal. eg. user tap on file and it will launch like other MAC OSX application works.
You could take a look at Platypus, an open source tool which lets you create Mac .app bundles from command line scripts, including Tcl scripts.

Mac OS X: ask for configuration during pkg install

I used Packages to create a.pkg installer for a Mac OS X LaunchDaemon.
During install, I would like the user to be able to provide a few values for the configuration file. The resulting file is a simple text configuration file which will be sourced by a shell script when it is run.
Is there some tool that would make it easy to create a fill-in form with a few text fields? This would be presented to the user during install, and then save the values provided (or make them available to a postinstall shell script).
If there is no such tool, I guess I could do it with the shell and a few reads in a Terminal. But in that case, how to start that interactive shell script from my postinstall script?
Not sure, you can do it with the Distribution.dist XML file. It is JavaScript, but I have not looked though the definitions, since it comes out all garbled on my current version of Safari.
The easiest would be to create a small applications dialog run from the script, which you have full control over.

Cocoa application won't run because Contents/MacOS/Application is not a Unix Executable

My application runs fine on my system, and also on several others.
However, some people can't run the application because the file in /Contents/MacOS/ApplicationName is not a Unix executable file.
Inputting the following line in the terminal forces the application to be executable, and solves the problem:
chmod +x ApplicationName
Obviously this is a very hacky way around the problem, and I don't want to tell users to enter chmod to run my application. What am I doing wrong? Why is it appearing as a Unix executable file on some systems, but not others? It could be a permissions issue...
at the moment, i transfer the app via dropbox to a client
Dropbox has problems with OS X metadata and permissions. Archive the application first (from the Finder context menu) and put the zip file into Dropbox.

Resources