Solved

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

Posted on 2008-10-10
5
2,057 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to Force Windows XP to Scan for driver update 14 126
HP PC Hardware Diagnostics UEFI 11 158
Batch to Restart Remote Computers 4 96
Event ID: 1202 / Source: SceCli 6 125
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 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