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

查看:37
本文介绍了在 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.

附言.我已经通过命令行、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天全站免登陆