Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:47 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question subject: Hows does Windows find Java?
PostPosted: Thu Oct 30, 2008 9:50 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

I have two verisons of Java installed, the JRE 1.5 under C:\Program
Files\Java\jre1.5.0_11
and JDK 1.6 under c:\Java\jdk1.6.0

How can I switch between using the two?

I thought it would work if i set JAVA_HOME to one of them,

e.g JAVA_HOME= C:\Program Files\Java\jre1.5.0_11
and then set PATH=%PATH%;%JAVA_HOME%\bin

then when I wanted to switch I could just set JAVA_HOME to
c:\Java\jdk1.6.0

But no, it doesn't work when i type java -version it still finds
version 1.5.0_11, which BTW I installed after installing the jdk 1.6.0.

SO it seems Windows is using some other method than searching PATH to
find JAVA. Is it in the registry? And does anyone know how I can
override this if it is?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Hows does Windows find Java?
PostPosted: Thu Oct 30, 2008 9:51 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 time
We need <classpath> be set to the path of the libraries for compiling and
running the class.
We need <path> to be set to the the path of executables for commands like
java and javac be understood.

U can define JAVA_HOME and then classpath and path are Java_Home/bin or lib


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Hows does Windows find Java?
PostPosted: Tue Jan 03, 2012 5:18 am 
Java installation puts four files into c:\windows\system32 folder:
java.exe
javaw.exe
javacpl.cpl
javaws.exe

So when you type "java -version" in cmd and jre\bin or jdk\bin folder is not set in the PATH before windows\system32, it executes java from there.
It looks into "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" to find JAVA_HOME and path to configuration files.

Hope this information helps you to understand magic with "java -version" command.


TOP
  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  

 Similar topics
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder
 java

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team