I resolved it by following below steps.
First ,this error is caused by space in java installation directory
(as in C:**Program Files**\Java\jdk1.8.0_241)
To overcome this you need to use quotes to set JAVA_HOME in some files in your Oracle home.
Few file where you need to check
oracle_home/middleware/oui/bin/launch.cmd
oracle_home/middleware/oui/bin/viewInventory.cmd
oracle_home/middleware/oui/bin/compareInventory.cmd
oracle_home/middleware/oui/bin/setProperty.cmd
oracle_home/middleware/oui/.globalEnv.properties
oracle_home/middleware/user_projects/domains/wls_domain/bin/setDomainEnv.cmd
oracle_home/middleware/user_projects/domains/wls_domain/bin/setNMJavaHome.cmd
oracle_home/middleware/user_projects/domains/wls_domain/init-info/domain-info.xml
oracle_home/middleware/user_projects/domains/wls_domain/init-info/startscript.xml
oracle_home/middleware/user_projects/domains/wls_domain/init-info/tokenValue.properties
oracle_home/middleware/user_projects/domains/wls_domain/init-`info/nodemanager-properties.xml
oracle_home/middleware/user_projects/domains/wls_domain/nodemanager/nodemanager.properties
In the above files if you find any lines like
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_241
if NOT exist %JAVA_HOME%\lib
set JAVA_HOME=%JAVA_HOME%
set JAVA_HOME=%%~fsi
Modify them to below format with quotes and save them.
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_241"
if NOT exist "%JAVA_HOME%\lib"
set "JAVA_HOME=%JAVA_HOME%"
set "JAVA_HOME=%%~fsi"
`````
Now your system will recognize the java home without trouble