1

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!

0

3 Answers 3

1

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 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you it works on Windows now. But what if I converted it to an exe file, how should I run?
0

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

When you export jar file from Eclipse, you can specify the Main Class, so you need not edit the manifest file manually.
0

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.

2 Comments

It works with jar file now, but not with exe file. I double clicked and there is nothing to show with exe
@Zoe I have updated my answer , check if that works for you (if you're still looking for an answer ;))

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.