在mac 10.8上执行jar [英] Executing a jar on mac 10.8

查看:111
本文介绍了在mac 10.8上执行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然这似乎是一个相当明显的问题,但我无法在网上找到答案。

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

创建jar文件后,我可以成功运行它命令行说

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

java -jar filename.jar

但是,我希望这个文件更加用户友好,换句话说,双击运行。出于某种原因,当我双击jar文件时,mac jar启动器(Jar\ Launcher.app)打开,暂停一秒然后关闭。我很感激帮助。

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。我通过命令行,bluej和eclipse制作了jar文件,这些方法都没有解决问题。

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

推荐答案

我会创建一个shell脚本将其封装在终端中:

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

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

我添加了暂停,但除非你的java应用程序立即达到终止,否则它不一定是必要的(你可以在java行之后停止shell脚本)。

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).

这篇关于在mac 10.8上执行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆