Solved

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

Posted on 2008-10-10
5
2,064 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

717 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