'How to run a .jar in mac?

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?



Solution 1:[1]

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.

Solution 2:[2]

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.

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Java D
Solution 3 Fahima Mokhtari