Solved

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

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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