Tuesday, 27 August 2013

Unable to set JAVA_HOME path into environment variable

Unable to set JAVA_HOME path into environment variable

I'm able to get PATH and JAVA_HOME on command prompt . But when i see the
environment variable then i cant see these variables set in Control
Panel\System and Security\System\Advanced System
Properties\variables............ I think code does not set them
permanently. If i double click the batch file for the second time its
showing message that "java.exe not found".
I'm unable to figure out where i'm missing out or written code wrongly?
i'm working on Windows 7
Code Tried :-
@echo off
SET JAVA_HOME=
for /f %%j in ("java.exe") do set JAVA_HOME=%%~dp$PATH:j
IF DEFINED JAVA_HOME GOTO :JAVA_FOUND
:JAVA_NOT_FOUND
@echo java.exe not found
PAUSE
CD C:\Users\Pathfinder\Desktop
ECHO "Time In"
jdk-6u43-windows-i586.exe /s "/v\"/qn ADDLOCAL=ALL REBOOT=Suppress
JAVAUPDATE=0
CUSTOM=1\""
timeout /t 10 /nobreak
ECHO "Time Out"
set path="C:\Program Files (x86)\Java\jre6\bin";%path%
@echo PATH= %path%
set JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_43\bin";%JAVA_HOME%
@echo JAVA_HOME = %JAVA_HOME%
GOTO :END
:JAVA_FOUND
@echo JAVA_HOME = %JAVA_HOME%
ECHO "ok1"
PAUSE
@echo JAVA_HOME = %JAVA_HOME%
PAUSE
:END

No comments:

Post a Comment