Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

java -version

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Also, this is what happens in Linux and UNIX too.
 
Marshal
Posts: 70716
288
  • Mark post as helpful
  • send pies
  • 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: 22028
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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: 70716
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Rob. That explained it all.
 
Menen Zwerky
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
 
It's exactly the same and completely different as this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic