Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-10
5
Medium Priority
?
2,072 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 1000 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 1000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 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