0

I'm using a Mac Pro 64bit Mojave.

Is it possible to create a .command or .sh or some other low-effort "launcher" for a Java program where all of the compiled code is in the "plugins" dir that does not open a terminal?

My situation is this: I'm tasked with making an old Java 1.6 project, once compiled, work under Java 7 on Mac Mojave.

Initially my issue was that the compiled launcher demanded Java 1.6 "legacy" be installed first where this is a contraint that no, we must not install other JREs before running the app.

But I figured ou that if I make a .sh file which runs the app by pointing the Java 7 binary and passing in the main plugin as an argument I can run the app successfully:

#!/bin/bash
/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java
\ -classpath /SOFT/corporateAppName/plugins/org.eclipse.equinox.launcher_1.2.0v2.jar
\ org.eclipse.equinox.launcher.Main

If I then change the .sh to .command I then have a runner from GUI, no need for terminal to start it.

This could be acceptable for the client if it didn't also open a terminal.

The reason I'm not instead trying to have my build generate a mac binary that does not fail with with legacy Java 1.6 needed is because I feel that that is not likely to be doable/ might require a year of work :

  1. https://bugs.openjdk.java.net/browse/JDK-7131356
  2. https://github.com/s-u/rJava/issues/37
  3. https://stackoverflow.com/questions/27507016/no-java-runtime-error-in-os-x-10-10-using-oracles-1-8-0-jvm
  4. https://stackoverflow.com/questions/44009058/even-though-jre-8-is-installed-on-my-mac-no-java-runtime-present-requesting-t
  5. https://stackoverflow.com/questions/19533528/installing-java-on-os-x-10-9-mavericks

The common solution to this seems to be to give in and install the version of Java that macOS asks for and it will not really use it, only for init, or migrate to a version of Java in which the bug is not present (10+) neither of which are an option.

Unless there is actually a way I can change my jenkins-ant-cocoa build process in order for it to generate a launcher that would not present this bug, or also altering the binary launcher in a way that fixes this.

  • You could use Automator to make a script that runs a shell script – Ezekiel Elin May 13 at 15:36
  • again, this would require the client install something extra. – tatsu May 13 at 16:33
  • Why not try bundling it into an app? Then you can just place the shell script in the MacOS folder of the app, and it'll work like a normal macOS app. – abc May 13 at 17:05
  • Yeah, you can run a shell script from inside an application without opening terminal – Ezekiel Elin May 13 at 17:59
  • how do you do this? – tatsu May 13 at 21:06

You must log in to answer this question.

Browse other questions tagged .