0

Is it possible to use "Jar Launcher" on Mac to pass command line arguments to a java app? For example:

open myApp.jar --args -hello

This ought to run myApp and pass it "-hello" but it doesn't.

I'm on High Sierra 10.13.6. This comes with a "Jar Launcher". It's /System/Libary/CoreServices/Jar\ Launcher.app.

I can run the jar file with Jar Launcher, I did it from Finder and it works, but without command line arguments. After that I can run a command line "open myApp.jar" and that works too, the open command uses Jar Launcher to open it. So far so good.

Now I want to pass arguments, let's say "-hello"

I tried "open myApp.jar --args -hello". That does not work, the application does not receive the hello argument.

I can't figure out how to do this. Maybe the problem is with "Jar Launcher", maybe it won't pass arguments through to the java app?

I know this can be done by installing a full JDK and using the java command instead of the built-in Jar Launcher, or compiling my jar into a Mac executable. I'm not a developer, I'd like to know if I can achieve this just using what's shipped on my Mac.

Earlier versions of MacOs shipped with a more complete Java environment, and a lot of the help I find out there refers to earlier versions.

1 Answer 1

0

try creating a sh or command file where the jar file exists, eg myj.command. Then make edit with chmod7 755 so its executable in console.

the myj should be java -jar .jar --

1
  • You are explaining how to do this with "java". As I mentioned near the end of the question, that's not the challenge. The challenge is to do this without installing java, using only the app called "jar launcher" that is included with MacOS. It does appear that jar launcher will not pass arguments to the jar it launches.
    – jay613
    Oct 25, 2019 at 14:29

You must log in to answer this question.

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