The knowledge base is no longer actively updated, we have moved all content to our Community Support Forum

Can the installer autodetect if there is an existing Java(tm) installation in the system?

Author: BitRock Support       Date: October 30, 2007 09:33       Tags: Java® support
Actions

Yes, you can make the installer autodetect whether or not there is an existing Java(tm) installation in the system by using an <autodetectJava> action. If a suitable Java(tm) is found, the action will also create a number of variables, described later on. This action is usually placed at the <preInstallationActionList> and if no valid JRE or JDK is found, the installer will abort with an error listing the supported JREs and JDKs. The following example will select any Sun Microsystems JRE 1.3 or newer (for example, 1.3, 1.4, 1.5) or any IBM JRE with version number equal or greater than 1.4.2 but inside the 1.4 series (1.5 will not work at this time).

           <autodetectJava>
             <validVersionList>
               <validVersion>
                 <vendor>sun</vendor>
                 <minVersion>1.4.2</minVersion>
                 <maxVersion>1.4</maxVersion>
               </validVersion>
               <validVersion>
                 <vendor>ibm</vendor>
                 <minVersion>1.3</minVersion>
                 <maxVersion></maxVersion>
               </validVersion>
             </validVersionList>
           </autodetectJava>
Each element in the <validVersionList> contains the following fields:
  • vendor: sun (to allow only Sun Microsystems JREs,) ibm (to allow only IBM JREs) or empty (to allow any JRE.)
  • minVersion:Minimum supported version of the JRE. Leave empty to not require a minimum version.
  • maxVersion: Maximum supported version of the JRE. Leave empty to not require a maximum version. If specified only with major and minimum version numbers then it will match any number in the series. For example, 1.4 will match any 1.4.x version (1.4.1, 1.4.2, ...) but not a 1.5 series JRE.
  • requireJDK: Whether to require that the Java(tm) installation needs to be a JDK. By default, it is set to 0 so either a JDK or JRE will work.
Upon successful autodetection, the following installer variables will be created :
  • ${java_executable}: Path to the java(tm) command line binary (java.exe in Windows). For example /usr/bin/java, C:\Program Files\Java\j2re1.4.2_03\java.exe.
  • ${java_version}: For example, 1.4.2_03
  • ${java_version_major}: For example, 1.4
  • ${java_vendor}: sun or ibm.
Click here to download a sample project.xml file that integrates this functionality.

 

Comments

64 or 32 bit JRE

Author: Jerry Nairn       Date: January 27, 2011 17:27

Can I determine whether there is a 64 bit JRE on the platform?


x64 JRE

Author: BitRock Support       Date: January 28, 2011 11:41

Hi Jerry.

Are you referring to Windows? It is not currently possible to specify that the required JRE must be x64 but we could tweak the action so the 64bit versions are checked before the rest on 64bit platforms. This way, if you set promptUser=0 and a 64bit JRE matches the required criteria, it will be returned before other existing 32bit JREs.

Best regards,

Juanjo.


64 bit jre

Author: Jerry Nairn       Date: March 31, 2011 20:43

Sorry to leave this unanswered for so long. I would actually like to ask about detecting a 64-bit JRE for linux.