1

I'm trying to make a .app that will run a simple bash script to launch a java app. I found instructions for making a suitable .app container and running the .app runs my bash. Great.

The problem is, I want to put my java app inside the .app but i'm not sure how to get my bash script to launch it.

Here's my current script:

#! /bin/sh

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -jar -Xmx1g javaapp.jar&

The script runs and shuts down immediately. I'm assuming because it either can't find /java or javaapp.jar which I put in the .app container in the same folder as the bash script (MacOS)

Darren
  • 10,182
  • 20
  • 95
  • 162
  • You meant to type a space before the trailing ampersand? – malfunctioning Apr 29 '15 at 13:58
  • That made no difference, thanks. – Darren Apr 29 '15 at 14:06
  • Begin your script with `#!/bin/bash -x` which will give you debug output. Then you can see what's happening. – vastlysuperiorman Apr 29 '15 at 14:42
  • There's nowhere for the debug to go though. It doesn't open a shell. – Darren Apr 29 '15 at 14:43
  • Valid point... I'm assuming you checked to see that the script is executable? Also, would you mind posting a link to the instructions you followed so we can replicate? – vastlysuperiorman Apr 29 '15 at 14:44
  • This was how I created it, https://mathiasbynens.be/notes/shell-script-mac-apps it simply makes the correct folder structure. I have confirmed that the script runs by adding `osascript -e "tell app \"System Events\" to display dialog \"Testing\""` – Darren Apr 29 '15 at 15:08
  • Add `1>>/Users/[you]/jar.log 2>&1` to the end of the line calling the jar. Then you'll get any output from the command (stdout or stderr) written to a logfile. That may at least give you a hint if there's a problem with starting the jar. Also, you're starting the jar with an &, to run it in the background. Maybe you want to start it with `nohup` as well so it doesn't get closed when the parent script completes (e.g. `nohup command args >> output.log 2>&1 &`). – vastlysuperiorman Apr 29 '15 at 20:35
  • Thanks. If I put the .jar on my Desktop and put the path in the bash, it works fine. If I put it in the .app bundle next to the bash and use ./my.jar I get Error: Unable to access jarfile ./my.jar – Darren Apr 30 '15 at 09:08

0 Answers0