51

I've written a relatively simple java application. I have JDK on my PC, but I need it to run on a mac for school. The .jar runs perfectly on my PC, but I tested it on my Macintosh (which, BTW, does not have JDK installed).

Why isn't it running on mac? How can I fix this? Is fixing it even possible?

2
  • does the mac have a JRE? If no that could be your problem right there. try java -jar <jar_file>.jar Commented May 30, 2013 at 4:44
  • What version of the JDK are you using to build the Jar? What version of Java is on the Mac? Commented May 30, 2013 at 4:45

3 Answers 3

97

You don't need JDK to run Java based programs. JDK is for development which stands for Java Development Kit.

You need JRE which should be there in Mac.

Try: java -jar Myjar_file.jar

EDIT: According to this article, for Mac OS 10

The Java runtime is no longer installed automatically as part of the OS installation.

Then, you need to install JRE to your machine.

Sign up to request clarification or add additional context in comments.

4 Comments

Mac no longer ships the JRE with the OS. It's installed the first time you try to use it. I'm not sure if java from the command line should do it but regardless there's a good chance it will need to be installed
@ChrisThompson: Well.. If that's the case. It will need to be installed.. Thanks for update. :)
@ChrisThompson - What do you mean by "it's installed the first time you try to use it?"
@ChrisThompson It still comes with max by default.
9

Make Executable your jar and after that double click on it on Mac OS then it works successfully.

sudo chmod +x filename.jar

Try this, I hope this works.

1 Comment

In my case, I also had to add this command on the terminal: java -jar Myjar_file.jar and right after, the installation process will start
0

I made the jar file executable as indicated by @Java D: sudo chmod +x filename.jar, and then I ran from the terminal Java -jar filename.jar as indicated in another answer by @Hardik Mishra. The installation process will start right after it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.