0

Let say I am not a java developer and an ordinary person, and installing any application that is written in Java. So, do I need to first install the JRE or no all operating systems already have JRE installed on them?

Stack Overflow
  • 1
  • 5
  • 23
  • 51
  • 1
    No, most systems would not already have a JRE installed. You should expect your clients to need to install it first. – Carcigenicate May 31 '19 at 21:49
  • thanks, Mr. Carcigenicate can you please tell me how the java applications start when we click on the application icon instead of going to command line interface and typing `java ProgramClassFile` to run that file (the process that we usually use during learning core Java). How the java application start by clicking on the application icon? Do they point the JRE environment variable internally? What's the scenario behind the scene? – Stack Overflow May 31 '19 at 21:53
  • In most systems I've used, you have to explicitly tell the OS to associate JARs with `java`. On Windows, that's usually just achieved by right clicking on it and saying "open with". – Carcigenicate May 31 '19 at 21:55
  • but I have seen some of the programs written in Java that runs directly having the `.exe` file extension without the need to use the `open with` option on Windows OS. How do they work? – Stack Overflow May 31 '19 at 21:57
  • Java compiled to an exe defeats most of the purpose of targeting the JRE in the first place. You lose interoperability if you target a specific OS; unless you recompile for every platform you want to target. – Carcigenicate May 31 '19 at 21:59
  • So, you mean it is also possible to create the .exe file of java program that only targets the Windows operating system? Without the need of JRE? – Stack Overflow May 31 '19 at 22:01
  • Yes. I've never done it before, but it is possible. A quick google search should yield answers though. – Carcigenicate May 31 '19 at 22:02
  • Note exe's are specific to Windows. You won't be able to use them elsewhere without a virtual machine, and at that point you might as well just use the JAR. – Carcigenicate May 31 '19 at 22:04
  • 3
    As of Java 11, there is no separate JRE. You are expected to distribute your application as a linked image, which is actually a file tree that includes a stripped-down JRE consisting of only the modules your application requires. See https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre. – VGR May 31 '19 at 22:47
  • A note: MacOS will prompt users to install Java 6 if they try to run something Java. – Benjamin Urquhart Jun 01 '19 at 00:28

2 Answers2

3

Do all operating systems already have JRE installed for running java applications?

No.

First of all, Java is not necessarily available for all operating systems. (It is probably available for most operating systems that are targeted by your application ... but it might not be.)

Secondly, most operating system platforms don't have Java installed by default. Indeed many OS vendors don't support Java at all: Java is provided by a 3rd-party vendor.

So, do I need to first install the JRE or no all operating systems already have JRE installed on them?

Prior to Java 9, the answer is that you have to install a JRE or a JDK. This can be done by downloading and installing it directly, or installing it via a package management system on some OSes. It can also be done by embedding a JRE in your application's installer.

From Java 9 onwards, you can also use "jlink" to create an executable that contains a cut-down JRE which is tailored to run your application on a specific target platform. This is the approach recommended by Oracle for people who want to distribute "consumer grade" Java applications.

And from Java 11 onwards, for some Java vendors (Oracle for example), the JRE option is no longer available. For these vendors, if you want "full" Java to run your application, you / your users need to install a JDK.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

The Java Runtime Environment has nothing to do with the OS. You could install any OS with or without the JRE. If you installed the OS yourself, I'd guess it doesn't have it. If you bought the computer with the OS on it, it depends who you bought it from.

Checking if you have JRE installed is pretty much the same on all OS. Open a Terminal (on windows run CMD) and type java --version.

If you don't have it, you need to install it. Just google install JRE on [insert your os here]

  • My question is different from your answer. Sir actually i just wanted to know that whether all operating systems also contains/installs jre tool by default for java applications or no i have to install it separately? Because java applications runs on jvm that is subsystem of jre to run applications written in Java. – Stack Overflow Jun 01 '19 at 00:34