Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

how to run same java program on jdk6, jdk7, jdk8 on my laptop

Hi,

how to run same java program on jdk6, jdk7, jdk8 on my laptop to compare various releases of JDK. How to set various classpaths with jdk6,jdk7, jdk8 nd give javac and java commands from console. please advise
SOLUTION
Avatar of Nguyen Doan Tien
Nguyen Doan Tien
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

can i have dedicated folders for each say C drive set to jdk 6
D drive for jdk 7
E drive for jdk8?
so that i do not need to run that batch file everytime?
I think you don't need to have dedicated drivers. You can put them to the same java folder but different version. And don't forget that way to temporarily change JAVA_HOME. When we  re-start SYSTEM_PATH will be restored by the setting in environtment variable.
That's why we have to create the following batch files and run everytime we need.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

There's no need for all that. If you have your environment variables set up in the standard way, all you need to do is change JAVA_HOME before running the app

set JAVA_HOME=foo
java -jar thejar.jar

Select all
 
Open in new window

PATH in Windows should have the following at the front
%JAVA_HOME%\bin;
let me try
Avatar of gudii9

ASKER

i still need to try this. Any good video or tutorials on standard way of setting multiple JDKs?
You've just quoted what i told you to do - what's the problem?
Avatar of gudii9

ASKER

any good document with screenshots or vide0 on this to do step by step. i am not clear on how to do this? please advise
Avatar of gudii9

ASKER

, all you need to do is change JAVA_HOME before running the app

can i have more than one JAVA_HOME

How do i change quickly and re run(i guess i do not have to go to Advanced variables from --My Computer etc?
can i have more than one JAVA_HOME

No.


How do i change quickly and re run

set JAVA_HOME=C:\Some\New\Path
java Foo

Open in new window


That will do it (IF you've set the PATH properly to include %JAVA_HOME%\bin)
Avatar of gudii9

ASKER

set JAVA_HOME=C:\Some\New\Path
java Foo

(you mean when i open command promt in my windows 10 laptop


do like
C:\Users\xyx>set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_91\bin
C:\Users\xyx>javac Foo.java
C:\Users\xyx>java Foo

then
C:\Users\xyx>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_91\bin
C:\Users\xyx>javac Foo.java
C:\Users\xyx>java Foo

That will do it (IF you've set the PATH properly to include %JAVA_HOME%\bin)
//this one is from advanced variables of the computer as attached


PATH i have to change every time if i change from say jdk 7 to jdk 8 etc
pathJDK.png
JAVA_HOME does NOT include the bin directory. You don't need to change PATH at all if it's set like i showed
Avatar of gudii9

ASKER

f it's set like i showed

where ? how ?command prompt (or) My Compute -->Advanced Setting -->environmental variables?
Yes, in there
Avatar of gudii9

ASKER

you mean in
My Compute -->Advanced Setting -->environmental variables??