• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

java -version

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Context:

JAVA_HOME= C:\Programmi\Java\jdk-1.5_16

If i launch the java -version under C:\Programmi\Java\jdk-1.5_16\bin
I have :
C:\Programmi\Java\jdk-1.5_16\bin>java -version
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode)

With the java -version command launched somewhere I have:
C:\Sonic\testConsegna\BARI\SONIC-BIN\MQ7.5>java -version
CompilerOracle: exclude progress/message/broker/AgentQueueDispatcher$DispatchThr
ead.threadMain
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

Why the result 1.6 if instead in the java_home I have set 1.5?
Thanks Menen









 
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because it actually looks in PATH and not JAVA_HOME, so I assume there's a reference to the 1.6 installation folder in PATH.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say java -version in windows , it first looks for any java executable in the current directory.

If it does not find one, then it goes for PATH

As you have mentioned, you have tried java -version in the bin folders of 2 different versions of java. So, obviously you will get the version of the java executable in that particular folder.

Try java -version in any other folder and check.
 
Sandeep Sanaboyina
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, this is what happens in Linux and UNIX too.
 
Marshal
Posts: 76427
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sandeep Sanaboyina wrote:Also, this is what happens in Linux and UNIX too.

Are you sure about looking in the current directory as a default? I used not to be able to execute files in my current directory on Linux, until I added .: to my PATH.
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows adds an implicit . at the start of the PATH variable, Linux (or better: almost all Linux shells like bash, csh, etc) doesn't.
 
Campbell Ritchie
Marshal
Posts: 76427
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Rob. That explained it all.
 
Menen Zwerky
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I had to put the JAVA_HOME at the start of the path and now it does work fine
By Menen
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic