How to find out why a second java installation is used and not the first?

M

Mark Sizzler

I have currently 2 java installation on my hard disc:

D:\java\v1.5

and

D:\project\test\jdk\v1.6

The environment variables JAVA_HOME and PATH point to the second java installations
mentioned above.

So when I open a command prompt and enter:

java -version

I got an answer

v1.5

Why??


How is the older java version able to have priority over the one entered in the environment variables?

Is there a way to get the path the the currently used java.exe? Something like

java -showownpath


Mark
 
R

RedGrittyBrick

Mark said:
I have currently 2 java installation on my hard disc:

D:\java\v1.5

and

D:\project\test\jdk\v1.6

The environment variables JAVA_HOME and PATH point to the second java installations
mentioned above.

So when I open a command prompt and enter:

java -version

I got an answer

v1.5

Why??


How is the older java version able to have priority over the one entered in the environment variables?

Have a look in C:\Windows\System32, do you have java.exe in there? In
PATH does C:\Windows\System32 occur earlier than D:\project\test\jdk\v1.6?
 
M

Mark Space

Mark said:
Is there a way to get the path the the currently used java.exe? Something like


For Windows it's "path" and for Unix it's "echo $PATH"

Which are you running?
 
M

Mark Space

RedGrittyBrick said:
Have a look in C:\Windows\System32, do you have java.exe in there? In
PATH does C:\Windows\System32 occur earlier than D:\project\test\jdk\v1.6?


Yeah, obviously he was using Windows. That was silly of me. I would
not have thought to look in System32, why the heck would anyone put an
executable there?

I just realized that Cygwin has a "where" command that works perfectly
well with the Windows shell:

C:\Users\Brenden>where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.6.0\bin\java.exe

C:\Users\Brenden>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)


The OP can get Cygwin here:

http://www.cygwin.com/
 
K

Knute Johnson

Mark said:
I have currently 2 java installation on my hard disc:

D:\java\v1.5

and

D:\project\test\jdk\v1.6

The environment variables JAVA_HOME and PATH point to the second java installations
mentioned above.

So when I open a command prompt and enter:

java -version

I got an answer

v1.5

Why??


How is the older java version able to have priority over the one entered in the environment variables?

Is there a way to get the path the the currently used java.exe? Something like

java -showownpath


Mark

When you install the Java JRE onto Windows, the last one wins in the
'who gets run from the command line' race. Windows does not care about
any of the environment variables. So if you want to use a specific JRE,
just call that java.exe specifically and it will work fine.
 
A

Arne Vajhøj

Mark said:
Yeah, obviously he was using Windows. That was silly of me. I would
not have thought to look in System32, why the heck would anyone put an
executable there?

Someone who do not expect Windows users to be able to set PATH.

Arne
 
1

1 connu

Mark Sizzler said:
I have currently 2 java installation on my hard disc:

D:\java\v1.5

and

D:\project\test\jdk\v1.6

The environment variables JAVA_HOME and PATH point to the second java installations
mentioned above.

So when I open a command prompt and enter:

java -version

I got an answer

v1.5

Why??
Your path is the way to find an program. You probably have D:\java\v1.5\bin before D:\project\test\jdk\v1.6\bin in your PATH.
Anyway, you can set your path in order to use the jdk you want.
 
C

Chris P. Bacon

(e-mail address removed) (Mark Sizzler) wrote in

I have currently 2 java installation on my hard disc:

D:\java\v1.5

and

D:\project\test\jdk\v1.6

The environment variables JAVA_HOME and PATH point to the second java
installations mentioned above.

So when I open a command prompt and enter:

java -version

I got an answer

v1.5

Why??


How is the older java version able to have priority over the one
entered in the environment variables?

Is there a way to get the path the the currently used java.exe?
Something like

java -showownpath


Mark

Make sure that D:\project\test\jdk\v1.6\bin is higher on your PATH than
D:\java\v1.5\bin
 
J

Jan Thomä

I have currently 2 java installation on my hard disc:
The environment variables JAVA_HOME and PATH point to the second java
installations
mentioned above.

How is the older java version able to have priority over the one
entered in the environment variables?

When installing Java on Windows, it puts a copy of Java.exe into the
Windows folder. This folder is usually first on your path therefore it
picks this copy. You could try to put the path to your 1.6 installation
as FIRST entry on your PATH variable. This should do the trick.

Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top