How to Enable Java on Mac

A colleague showed you a written program operation Java very useful for the work you are doing but, having never dealt with this language before, you have not the faintest idea how to run it on your Mac. Without losing heart, you immediately opened Google looking for a solution to your problem and you happened to be right here on my website.

If this is the way things are, then know that you are in the right place, at the right time! In fact, below I will explain to you in detail how to enable java on mac, so as to be able to easily execute programs written using the aforementioned programming language.

So, without hesitating a moment longer, make yourself comfortable and carefully read everything I have to explain to you on the subject: I am sure that, at the end of reading this guide, you will have acquired the necessary skills to easily reach the goal you want. you are fixed. That said, there is nothing left for me to do but wish you good reading and good work!

Preliminary Information

Before getting to the heart of this guide and explaining, in practice, how to enable Java on Mac, let me give you some more information on the subject.

In order to allow programs written in the Java language to run, a software called JRE (Java Runtime Environment): if you had never heard of it, it is a program that contains all the components necessary to successfully start many categories of programs written in Java. JRE is available for all major desktop platforms (Windows, Linux and, of course, macOS) and can be downloaded from the Internet completely free of charge.

Another "variant" of the Java execution environment is, instead, JDK is Java Development Kit: it adds, in addition to the tools made available by JRE, other add-ons that allow you to create real ones using Java. JDK is software licensed from Oracle and downloadable for free from the Internet.

Having made this necessary premise, you are certainly wondering which of the two versions is more convenient, right? Well, it all depends on what your needs are: if you only have to run programs written in the Java language, installing JRE is more than enough. If, on the other hand, you intend to learn Java and start writing programs yourself, then you will need to install the entire JDK environment.

The purpose of this tutorial will be, precisely, to guide you in the installation of JRE or JDK on macOS and to show you, later, how to run the most popular types of Java programs and how to enable the related plugin in the browser, where possible.

How to Install Java on Mac

Having clarified the difference between the two main versions of the Java environment currently existing, it is time to move on to the work and show you, in practice, how to enable java on mac. Below I will explain how to proceed both with the installation of the JRE, that is the execution-only environment of Java applications, and with that of the JDK, that is the complete development environment.

JRE

Install Java Runtime Enviroment (JRE) on macOS is really very simple: to begin with, connected to the software download page, click on the button I accept all cookies, if necessary, then hit the button Java Free Download and, having reached the next page, press the button Accept and start free download, to get the software installation package. If prompted, click on the item Allow, in order to bypass the security restrictions imposed by Safari.

Once the download is complete, launch the fillet .dmg obtained and double-click on the program installation package (eg. Java X Update YYY) contained in the window that subsequently opens on the screen. To start installing the program, click on the button apriI inserted the administration password of the Mac (the same one you use to log in to the system, so to speak) and press the button OK, to overcome the security restrictions imposed by MacOS.

At this point, you just have to click on the button Install, in order to proceed with the Java setup. If everything went smoothly, after a few moments, a confirmation message should warn you that the software has been installed: when this happens, press the button Close, to finalize everything.

At this point, to verify that Java has been correctly installed on macOS, start the System preference clicking on the d-shaped icongear attached to the Dock bar and, when you reach the next window, check for the presence of the Java within the available options.

If you want to check the version of Java installed on your Mac or check for updates, click on the aforementioned icon, wait for the Java control panel to open and click on the tab Update, placed at the top.

JDK

If, on the other hand, you are interested in starting programming in Java and you want to get the development software Java Development Kit (or JDK), do this: connect to the suite's website, click on the button I accept all cookies, if necessary, then click on the button Java Download located in the center of the page (under the heading Java SE Downloads) and wait for the next page to load entirely.

At this point, locate the box Java SE Development Kit X.Y.Z (it should be at the bottom of the page), put the check mark next to the item Accept License Agreement and click on its link jdk-X.Y.Z_osx-x64_bin.dmg, in order to start downloading the JDK installation package. If necessary, click on the button Allow to bypass Safari's security restrictions.

Once you have the file containing the JDK environment, launch it, double-click the file .pkg contained within it and, to proceed with the installation of the software, click in sequence on the buttons Continue e Install. When prompted, enter the administration password on your Mac, press the button Install software and, at the end of the process, click on the button Close, to exit the installation program. Finally, choose whether or not to move the latter to the trash can by clicking on the buttons Move or on Don't move it e OK.

Now, to verify that the JDK installation was successful, open the terminal macOS (you can call it from the Other . Launchpad or from the menu Or> Utility Finder) and type the command java -version, I follow the pressure of the tasto Submit.

How to Run a Java Program

Now that you have finally managed to enable Java on Mac, the time has come to understand how to start programs written through this programming language. In the home environment, you may find yourself in the presence of at least three different categories of Java programs: executables with .class, executables with extension .jar and executables with extension .JNLP. Below is a list of the characteristics of each of these file types, along with how to open them.

File .class

This file category refers to the binary file from a previously compiled Java class (using the command javac ClassName.java). Clearly, an executable of this type must be located inside the folder (of the package) containing the other classes and other methods necessary for its execution, otherwise a runtime error will be generated.

To run a file with a .class extension, start the terminal macOS (available from the menu Or> Utility Finder), move to the folder containing the .class file using the command cd / Path / Folder (With art. cd ~/Desktop, if the executable is on the desktop), press the key Submit of the keyboard and, in the same way, give the command Java FileName, omitting the .class extension.

File .jar

Files with extension .jar, unlike the previous ones, they contain everything necessary to be executed by any computer equipped with JRE or JDK, regardless of its location.

On macOS, you can run a file with the .jar extension by right clicking on it, selecting the entry apri from the contextual menu proposed and clicking on the button again apri, to overcome the restrictions imposed by macOS.

In case of problems, you can also start a file of this type directly from the terminal: calls the latter from the folder Other of the Launchpad, navigate to the folder containing the .jar file using the command cd / Path / Folder (With art. cd ~/Desktop) and run it with the command java -jar NomeFile.jar. For more information, feel free to read my guide on how to open JAR files.

File .JNLP

L'estensione .JNLP identifies a particular file designed to start a program written in Java, the code of which however resides on the Internet: at startup, this type of application downloads a copy of the file locally, launching immediately after the first valid instruction for its execution. In other words, a JNLP file is the "launcher" of another program written in Java.

That said, the easiest way to start a file of this type is to right-click on its icon, then select the item apri from the context menu displayed on the screen. Finally, click on the button apri to overcome the security restrictions imposed by macOS and continue running the program.

If you see fit, be aware that JNLP files can also be started from terminal: starts the latter by recalling it from the folder Other of the Launchpad, move to the folder containing the JNLP file of your interest by typing the command cd / Path / Folder (With art. cd ~ / Desktop) and, finally, executes the file by issuing the command javaws NomeFile.JNLP. For more information, check out my tutorial on how to open JNLP files.

How to Enable Java in the Browser

How do you say? You have installed Java with the intended intent to run web applications using the browser that you usually use on the Mac? In this case, I don't think I have good news to give you: for strictly security-related issues, browsers Safari (a starting from version 12), Chrome Firefox no longer support the use of the plugin on macOS. The Java plugin, on the other hand, works with Safari versions lower than 12.

So, if you have the aforementioned browser version and want to use the Java plugin, first make sure that Java is enabled for remote code execution: to check this, access the System preference on the Mac (by clicking on the d-shaped icongear located on the Dock), click on the icon Java and, in the next window, click on the tab Safety.

Next, check for the check mark next to the item Enable Java content for the browser and Web Start applications (otherwise do it yourself) and click on the buttons Apply OK per confermare I modified it.

Now, launch your browser Safari, go to the menu Safari> Preferences and click on the tab Safety, located at the top of the new panel that appears on the screen. At this point, click on the items Plugin consent Manage website settings, select the dicitura Java and, using the drop-down menu When visiting other websites, select the option that best suits your needs, to be chosen from AllowAlways allowed or Ask. To conclude and apply the changes, click on the button end.

Now, you can quickly test the functionality of the Java plugin on Safari in the following way: connected to this web page, click on the button I accept all cookies, Then Accetta and continue and finally, su Run: if the plugin has been successfully enabled, you should see the message appear Congratulations, accompanied by a green tick.

When you are done, remember to deactivate Java again in Safari, following the same procedure seen above and selecting the option for deactivate how the Java plugin works from the drop-down menu When visiting other websites.