Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
111 views
in Technique[技术] by (71.8m points)

java - Executing a jar on mac 10.8

Although this seems like a rather obvious question, I couldn't find the answer anywhere online.

After I create the jar file, I can run it successfully using the command line by saying

java -jar filename.jar

However, I want this file to be a bit more user-friendly, in other words, run on double click. For some reason when I double click the jar file the mac jar launcher (Jar Launcher.app) opens, pauses one second then closes. I appreciate the help.

Ps. I have made jar files through the command line, bluej, and eclipse, none of these ways solved the issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would create a shell script to enclose it in terminal:

#!/bin/bash
java -jar yourjarfile.jar
read -p 'Hit [Enter] to continue...'

I added pause, but unless your java application is immediately reaching termination, it shouldn't be necessary (you can stop the shell script after the "java" line).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...