I am trying to set JAVA_HOME dynamically. I am trying to set the value in the registry but that is not getting refreshed. For example my scenario is this
1) Run a java Program
2) User selects one java version out of many available java versions
3) User clicks a button which internally takes the input and changes the java version.
I tried doing the following code snippet
On doing the above I could able to change the registry value but when I run java applications it is still using the previous java version not the changed one.
Can anyone help me how to change the java version by using the registry or by any other means?
Please note that setx command cannot be used in my machine since mine is Windows XP so it would be very helpful if anyone help me to provide a solution other than what mentioned.
Neither java nor javac take any notice of JAVA_HOME . Some applications such as Tomcat use JAVA_HOME in their startup scripts but Java does not use JAVA_HOME.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
S. Vijay wrote:
mine is Windows XP so it would be very helpful if anyone help me to provide a solution other than what mentioned.
hmm. good even I am using xp. as james said JAVA_HOME is used by some other application needs to find out where is java has been installed.if you want more specific answer then elaborate.
S. Vijay
Ranch Hand
Joined: Jul 10, 2009
Posts: 44
posted
0
Ok I will explain in detail what I am trying to do
Please see the attachment image
When I change the Java home version then my jdk version gets changed if I use the Environment Variables from System Properties windows GUI.
For example if I am using JDK1.5 and if I change the JAVA_HOME version to JDK1.6 then the java version changes to the corresponding 1.6 version.
So in my application I created a combo box which displays the different java version and when the user selects the version of his choice and click the change button then my application has to change the java version to the corresponding version.
I tried the code which was mentioned in my first post. This makes change to the registry variable and I can see the corresponding changes in the environment variable settings but still I see previous java version used not the changed one.