Install JRE if not installed

I searched on the Internet and in this forum the correct way to enable the Java Runtime Environment with my Java application.

I know that the JRE is machine dependent and therefore the JRE for providing my application will change if I want to deploy for MAC or Linux, for example.

What I really want to know (assuming what I said earlier is correct):

"Is there a way to check if the JRE is installed on the client machine, and if it is not installed before trying to run my application?"

Because I do not think this is possible:

Do you think I should deploy my application using a JRE folder adapted to the client system and start my application using a script using java.exe contained in the JRE folder?

This avoids the installation of any Java materials, but for me it does not seem like good practice ...

+4
source share
2 answers

If your application is client-side, I would suggest both options: install with and without JRE. Many Java applications offer both installations. For example, a SmartGit application allows you to download an installation using a JRE or one that uses an existing JRE (where its users must have a compatible version of java). Many application servers have their own JDK, already included in the installation.

So, combining the deployment with your JRE is fine if you don't want any problems with your clients; however, I would allow installation without JRE (to satisfy picky :).

If your application is server-side, it usually does not come with a JRE, but again, this is not the rule.

In addition, your run / install script can verify that the JRE or JDK is installed correctly (if JAVA_HOME, etc. is installed), and then exit if there is no JRE. Moreover, the script can even load Java and install it locally - although it would be more practical to use only the bundled JRE that you prepared with the application. Or, if a JRE is detected, you can ask the user if they want to use existing Java or bundled.

JRE binding is not a big deal. Even sometimes, I install a Java application with JRE enabled because I turned on my system, for example. A new version or 64-bit version of Java that is not supported by the application, etc.

Hope this helps;)

+3
source

java -version command in Windows CMD reports the version of the JVM; therefore, you can decide whether you need to install or not based on the output of this command.

C: \ Users \ 501200I958> java -version

java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

+1
source

All Articles