Solved

How To Switch Between Two Different Java Versions For Two Different 3rd Party Apps?

Posted on 2008-10-10
5
2,047 Views
Last Modified: 2012-05-05
There are two different 3rd party applications that use two different Java versions -- version 1.4.2_10 and 1.5.0_11 that we need to install on several user's boxes.

I would like to create a batch file (on an XP box) that will first switch the java versions and then run the applications.

What would that Java switching code look like?

Thanks.
0
Comment
Question by:jeffrey_b_lee
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
gurutc earned 250 total points
ID: 22689187
Hi,

First find out the value for this variable in your registry:

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion

For this example we'll say it's 1.4

Under HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment you'll likely see several different keys for the installed JRE versions.  On my system I have 1.3, 1.3.1_06, 1.4, and 1.4.2_17.  I'm interested in what the 1.4 key has for values.

If i export the 1.4 key to a file called jre14.reg I see it looks like this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.4]
"JavaHome"="C:\\Program Files\\Java\\j2re1.4.2_17"
"RuntimeLib"="C:\\Program Files\\Java\\j2re1.4.2_17\\bin\\client\\jvm.dll"
"MicroVersion"="2"

From this I can tell that my version in use is the 1.4.2_17 release.  So when you export the key that the CurrentVersion points to, you'll see what your in use version is.  Now make two copies of the file of the exported key that your CurrentVersion points to.  Then edit the first *.reg file to have the correct path to your installed 1.4.2_10 version and edit the second to have the correct path to your installed 1.5.0_11 version.  Name each file appropriately, such as jre142.reg and jre150.reg.

Now you just have to use the regedit command in your batch file to merge the required registry settings to support the desired jre version before you run your apps and then merge the other one back after.

Example batch file:

echo off
regedit /s jre142.reg
application.exe
regedit /s jre150.reg

You may have to tweak some permissions, but it's usually not too techy.

Good Luck,

- gurutc
0
 
LVL 50

Assisted Solution

by:jcimarron
jcimarron earned 250 total points
ID: 22689422
jeffrey_b_lee--IE Tools|Internet Options|Advanced tab|Java section.  Check the box for the version you want to use.
Since switching by this method requires a reboot I wonder if a reboot would also be necessary using a batch file.
Those versions of Java are very much out of date.  1.6.0_07 now current.
0
 
LVL 16

Expert Comment

by:gurutc
ID: 22866854
cool with me - gurutc
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now