I am building a small Java program for a Mac user who is an absolute novice when it comes to computing. Therefore, I would like to give him one file to execute, perhaps via a script. Before, I just gave the .jar file, which would run perfectly, but now I have to add VM arguments (max heap space). Unfortunately, I’m not well acquianted with OSX. So far, I was able to give the .jar and a .command file containing the text
#!/bin/bash
java -jar -ms128m -mx512m -jar file.jar
However, this gives the message ‘The file could not be executed because you do not have appropriate access privileges’. One solution is to use sudo in the console, but I’m afraid this is too complex. Therefore my question:
- can I make a .command or other script run a java .jar file without going to the console?
- or, can I wrap the .jar file in some kind of Mac executable, including VM arguments? I found a similar solution (Launch4j) for windows.
- or, is there maybe another way to give a simple mail-downloadable, executable that runs a java program, but without installing any other programs?
edit: I do not have unlimited access to a Mac, so I would need a solution that does not require a Mac at each update of the .jar file.
Thanks a lot!
If you have a Mac you can try out the Jar Bundler. It come with XCode or perhaps you can find it here https://developer.apple.com/downloads. With this app you can make a 1 Click Mac Executable.
I don’t know if it’s possible with a Windows Eclipse version. Go to the Main-Class open the context menu and start the Export dialog. Search for Mac OS X application bundle and follow the steps.
Create an extra Java “starter” class which starts itself again. You can call with
ProcessBuilderanother jar like thisjava -Xms1024M -Xmx1024M -jar app.jar.