/build/static/layout/Breadcrumb_cap_w.png

Managing JRE.

Just a general query on how you go about managing Java Runtime Environment installs in your environment.
We have a policy that installs JRE (5.0 Update 4)
We are finding that because applications such as Matlab and Maple install their own JRE it is causing problems with web Java applets that are trying to use the wrong version.
Ideally we would only like one install on our systems and to point all applications to use that install
Any advice on a best practise for this would be appreciated.

Thanks in advance

0 Comments   [ + ] Show comments

Answers (8)

Posted by: anonymous_9363 16 years ago
Red Belt
0
Ahhhhhhhhh....JRE...one of my favourites.

I *hate* JRE with a passion. Or, more correctly, I hate application developers who tie their apps to a specific JRE version. I have yet to come across an app which requires, say 1.4.0_10, but which won't quite happily work with 1.4.2_01. What I've generally done for these apps is to frig the relevant registry settings to fool the app into believing the version it requires is present. Thus, in the case I've quoted here, I export the 1.4.2_01 branch to a .REG, edit it so that it mocks up the "required" 1.4.0_10 entries, save the changes in a new .REG then import that into the project. I also have a script to produce the same result in a Custom Action.

There will still be apps (do I recall IBM iSeries Access as being among them?) which install a discrete JRE but they're generally self-contained in that application's folder tree and don't mess with 'C:\Program Files\Java' and/or 'HKLM\Software\Javasoft'.
Posted by: danr29 16 years ago
Purple Belt
0
Lazy developers don't want to have to test their product each time a new version of JRE is released so they tie it to one particular version of JRE...that's great. That must be why we here use several custom applications that are still using JRE versions from around a year ago. I was totally unaware of using the registry trick to fool the application into thinking it's using the version of JRE that it's tied to...I'm definitely trying this out next JRE release!!!
Posted by: anonymous_9363 16 years ago
Red Belt
0
ORIGINAL: danr29
I was totally unaware of using the registry trick to fool the application into thinking it's using the version of JRE that it's tied to
Neither was I until I stumbled upon RegMon (now of course subsumed into ProcMon) many moons ago , which enabled me to see what the app was up to. Comparing the two JREs (i.e. what was installed and what the app wanted) the differences were so miniscule (IIRC, there was *one* JAR file which differed in size) that I thought I'd mock it up and see what happened. The user UAT'd and cleared the app and, ever since, I've used my script in such situations and have yet to have any negative feedback about app problems as a result.
Posted by: jimmyx 16 years ago
Purple Belt
0
Many thanks for your reply.
Fooling the app was my initial thought as well.

Any chance of having a look at your CA script?
Thanks again
Posted by: anonymous_9363 16 years ago
Red Belt
0
This is the only one I have at my current location, one which alters only the part after the underscore. I'm sure I have the fuller version which handles major version, minor version and release on a USB pen drive. Somewhere.

Anyway, the bones are there: it'll be a snap to alter it to suit.

Option Explicit
'// Some DLLs fail to register if they don't see the exact version of the JRE they expect.
'// This script takes an existing entry and copies its entries into the ones required by the DLLs.
'// For example, if you have 1.5.0_06 and your app is expecting 1.5.0_01, all the entries relating
'// to 1.5.0_06 will be copied to identical entries beneath 1.5.0_01.
'// Equally, if you have 1.4.2_03 and your app requires 1.4.2_05, the entries for 1.4.2_03 will
'// be copied to 1.4.2_05.

Dim objWSHShell
Dim strMsg
Dim intPos
Dim strJavaPath
Dim strJavaTemp
Dim strJRERegRoot
Dim strJREVersion
Dim strJREFullVersion
Dim strRegRoot
Dim strRegKey
Dim strRegSubKey
Dim strRegValue
Dim strNewRegKey
Dim strNewRegSubKey
Dim strLeft
Dim strRight

'// Set the parameter sent to Sub Main to the flavour that your app is expecting
Call Main("11")

Sub Main(ByVal strNewVersion)
Set objWSHShell = CreateObject("WScript.Shell")

'// Find the JRE version
strJRERegRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
strRegKey = strJRERegRoot
strRegValue = "CurrentVersion"

On Error Resume Next

With objWSHShell
strJREVersion = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJREVersion) = 0 Then
'// No Java installed! Give up at this point
strMsg = "Unable to detect a valid installation of the Java Runtime environment (JRE)."
strMsg = strMsg & vbCRLF
strMsg = strMsg & "Please install JRE."
MsgBox strMsg,, "JREPatch"
Exit Sub
End If

strRegKey = strJRERegRoot & "\" & strJREVersion
strRegValue = "JavaHome"

On Error Resume Next
strJavaPath = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

intPos = InStrRev(UCase(strJavaPath), "\")

If intPos = 0 Then
'// No Java installed!
strMsg = "Java Runtime environment (JRE) is not installed on this workstation."
strMsg = strMsg & vbCRLF
strMsg = strMsg & "Please install JRE."
MsgBox strMsg,, WScript.ScriptName & ".JREPatch"
Exit Sub
End If

strJavaTemp = Mid(strJavaPath, intPos + 1, Len(strJavaPath) - intPos)

If UCase(Left(strJavaTemp, 3)) = "JRE" Then
strJREFullVersion= Right(strJavaTemp, Len(strJavaTemp) - 3)
Else
strJREFullVersion=strJavaTemp
End If

If UCase(Left(strJavaTemp, 4)) = "J2RE" Then
strJREFullVersion= Right(strJavaTemp, Len(strJavaTemp) - 4)
Else
strJREFullVersion=strJavaTemp
End If

'// Now we've got something, is there an underscore in the path already?
'// If so, we'll have to truncate that as well
intPos = InStr(UCase(strJREFullVersion), "_")
If intPos > 0 Then
strLeft = Left(strJREFullVersion, intPos - 1)
End If

'// Now we can start work
strRegRoot = "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Plug-in"
strRegSubKey = strJREFullVersion
strNewRegSubKey = strLeft & "_" & strNewVersion

strRegKey = strRegRoot & "\" & strRegSubKey
strNewRegKey = strRegRoot & "\" & strNewRegSubKey

strRegValue = "JavaHome"

On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
'// Write the new key first (not strictly necessary but good practise)
.RegWrite strRegRoot & "\" & strNewRegSubKey & "\", "", "REG_SZ"
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_SZ"
End If

strRegValue = "HideSystemTrayIcon"

On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_DWORD"
End If

strRegValue = "UseJava2IExplorer"

On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_DWORD"
End If



'// Now do Java Runtime Environment key
strRegRoot = "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment"
strRegSubKey = strJREFullVersion
strNewRegSubKey = strLeft & "_" & strNewVersion

strRegKey = strRegRoot & "\" & strRegSubKey
strNewRegKey = strRegRoot & "\" & strNewRegSubKey

strRegKey = strRegRoot & "\" & strRegSubKey
strNewRegKey = strRegRoot & "\" & strNewRegSubKey

strRegValue = "JavaHome"

On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
'// Write the new key first (not strictly necessary but good practise)
.RegWrite strRegRoot & "\" & strNewRegSubKey & "\", "", "REG_SZ"
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_SZ"
End If

strRegValue = "MicroVersion"
On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_SZ"
End If

strRegValue = "RuntimeLib"
On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_SZ"
End If


'// Now do Java Web Start key
strRegRoot = "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Web Start"
strRegSubKey = strJREFullVersion
strNewRegSubKey = strLeft & "_" & strNewVersion

strRegKey = strRegRoot & "\" & strRegSubKey
strNewRegKey = strRegRoot & "\" & strNewRegSubKey

strRegValue = "Home"

On Error Resume Next
strJavaTemp = .RegRead(strRegKey & "\" & strRegValue)
On Error Goto 0

If Len(strJavaTemp) > 0 Then
'// Write the new key first (not strictly necessary but good practise)
.RegWrite strRegRoot & "\" & strNewRegSubKey & "\", "", "REG_SZ"
.RegWrite strNewRegKey & "\" & strRegValue, strJavaTemp, "REG_SZ"
End If
End With

Set objWSHShell = Nothing
End Sub
Posted by: jimmyx 16 years ago
Purple Belt
0
Thanks for that info...Much appreciated.
Posted by: Nomi1985 14 years ago
Senior Yellow Belt
0
@VBScab:
I wonder if you ever found the script you mention which handles major version, minor version, and release? If you have it, would you mind sharing it? Thanks!
Posted by: anonymous_9363 14 years ago
Red Belt
0
Regrettably, the pen drive has passed to my son who obliterated its content :(

It shouldn't be too taxing to alter the one above, though.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ