Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bat file for jar

Tags:

java

I'm using a bat file to run my jar. The code in my bat file is this :

@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

like image 939
Darth Blue Ray Avatar asked May 29 '11 15:05

Darth Blue Ray


2 Answers

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

like image 174
IAmTimCorey Avatar answered Oct 15 '22 07:10

IAmTimCorey


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

like image 41
whirlwin Avatar answered Oct 15 '22 07:10

whirlwin