The program I write in Eclipse runs on console purely. I hope to export it to a jar file then use launch4j make it an executable .exe file. The program should desirably be opened in cmd or terminal on Mac once clicked. But it seems I can't open it with cmd and unless I used swing or awt, nothing to show when I clicked either jar file or exe file. So what is the problem and how should I do to make it runnable on cmd! PS:I dont want to type any command line, just click the jar file or exe file and it started to run on cmd or terminal!
3 Answers
You would possibly try script files for this task:
windows: run.bat
java -jar your.jar mac: run.sh
#!/bin/bash java -jar your.jar 1 Comment
launch4j could work on windows/osx/linux, but I think you need a mac to build the executable file. And the jar file itself can be run when double-clicked, if you specify the Main Class in META-INF/MANIFEST.MF file, like this:
Main-Class: com.xxx.xxx.YourClass After this, the jar file could be double-clicked to run.
1 Comment
This Answer shows the use of Jar Bundler to convert jar to executable native Mac OS X .app executables
I think you can give it a try. Enjoy!
Edit
Jar2Exe seems promising to convert jar file to executable for Windows and Linux Platform.
You can try them and let me know too if that work for you.