开发者

Bat file for jar

I'm using a bat file to run my jar. The code in my bat file is this 开发者_JAVA百科:

@echo off
java -cp analyser.jar be.model.Start
pause

This works fine for windows.

But it doesn't do anything at linux. I also need to be sure it will run on Mac


Bat files are specific to Windows. You would need to execute the command in Linux and Mac in a manner that is specific to those platforms. The actual java call should work the same, I believe. The one change to the java line would be if you had multiple items in the classpath. In that case, you would need to use a colon as a separator instead of a semicolon (which is what Windows uses). (Thanks to khachik for that tip)

For Linux, you would use Shell programming using a BASH script. Here is a link that will describe what you need to do:

http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

For Mac, you would probably use an AppleScript. Here is an article on how to get started with AppleScripts:

http://www.macosxautomation.com/applescript/firsttutorial/index.html


For Linux, why not use a .sh (shell) file?

As Biggs~ alreay said, the actual Java call should remain the same.

Update:

You will also have to make it executable by changing it's user permissions. To do this, use: chmod +x thescript.sh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜