EmuNewz Network
JPCSP start .bat says Java not exist due Windows command issue - Printable Version

+- EmuNewz Network (https://www.emunewz.net/forum)
+-- Forum: PSP Emulation (https://www.emunewz.net/forum/forumdisplay.php?fid=191)
+--- Forum: JPCSP Official Forum (https://www.emunewz.net/forum/forumdisplay.php?fid=51)
+---- Forum: General discussion (https://www.emunewz.net/forum/forumdisplay.php?fid=57)
+---- Thread: JPCSP start .bat says Java not exist due Windows command issue (/showthread.php?tid=75019)



JPCSP start .bat says Java not exist due Windows command issue - montcer9012 - 08-08-2012

Some users has been reporting that even they have installed Java 6 or 7 on architect x86/x64 the start JPCSP batch file says that Java is not found or the version is old.

It seems that some Windows version does not recognized the "REG" command making those lines becomes useless:
Code:
for /f "tokens=3* skip=2" %%a in ('reg query "%key%" /v CurrentVersion') do set JAVA_VERSION=%%a
for /f "tokens=2* skip=2" %%a in ('reg query "%key%\%JAVA_VERSION%" /v JavaHome') do set JAVA_HOME=%%b

This will become a problem to use JPCSP for non middle Windows users. The fastest (But not flawless) solution i found will be set directly where to run:
Code:
@echo off
set PATH=%PATH%;lib\;lib\windows-amd64\
echo Running Jpcsp 64bit...
"C:\Program Files\Java\jre7\bin\java" -Xmx1024m -Xss2m -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=64m -Djava.library.path=lib/windows-amd64 -jar bin/jpcsp.jar %*
:END

Instead registry search i suggest verify java.exe location whit something like:
Code:
FOR %Z IN (java.exe) DO SET JAVA_HOME=%~dpZ
That's just an idea; for now i go out so the search have to continued.
For now the best solution to this problem is use hyakki JPCSP Launcher.

Cheers.


RE: JPCSP start .bat says Java not exist due Windows command issue - gid15 - 08-09-2012

Could someone test if this script would better work?
I've tried to detect if the "reg" command is available.
Also, if the java command is not returning an error code of 0, a pause is added so that you can see any error message.

Code:
@echo off
set PATH=%PATH%;lib\;lib\windows-x86\

if NOT EXIST "%SystemRoot%\SysWOW64" goto JAVA32
set key=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment
goto JAVA

:JAVA32
set key=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

:JAVA
set JAVA_CMD=java.exe

rem Checking if the "reg" command is available
reg /? >NUL
if ERRORLEVEL 1 goto RUN

set JAVA_VERSION=
set JAVA_HOME=
for /f "tokens=3* skip=2" %%a in ('reg query "%key%" /v CurrentVersion') do set JAVA_VERSION=%%a
for /f "tokens=2* skip=2" %%a in ('reg query "%key%\%JAVA_VERSION%" /v JavaHome') do set JAVA_HOME=%%b

set JAVA_CMD=%JAVA_HOME%\bin\java.exe
if not exist "%JAVA_CMD%" goto JAVAMISSING

:RUN
echo Running Jpcsp 32bit...
"%JAVA_CMD%" -Xmx1024m -Xss2m -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=64m -Djava.library.path=lib/windows-x86 -jar bin/jpcsp.jar %*
if ERRORLEVEL 1 goto PAUSE
goto END

:JAVAMISSING
echo The required version of Java has not been installed or isn't recognized.
echo Go to http://java.sun.com to install the 32bit Java JRE.

:PAUSE
pause

:END



RE: JPCSP start .bat says Java not exist due Windows command issue - montcer9012 - 08-09-2012

It will work. If you change:
Code:
reg /? >NUL
if ERRORLEVEL 1 goto RUN
For:
Code:
ASDF /? >NUL
if ERRORLEVEL 1 goto RUN
JPCSP will start.

However, certain users install a Java version over older installed versions. I am not sure but i think maybe Windows will do something weird (Start the older Java instead newest?) if several Java versions are installed; this is why "java.exe fix" are not flawless.


RE: JPCSP start .bat says Java not exist due Windows command issue - gid15 - 08-09-2012

I've just seen that java.exe has an option to start the 32 or 64 bit version.
Could someone try the following on a 64 bit system where both versions are installed:
Code:
java -d32 -help
echo %ERRORLEVEL%
java -d64 -help
echo %ERRORLEVEL%
Thanks!

Edit: this option is only available from Java 7. It is not available on Java 6.


RE: JPCSP start .bat says Java not exist due Windows command issue - montcer9012 - 08-09-2012

It works!

Here's the result: (I add "Testing -d32/-d64 on each section)"
Code:
Testing -d32 switch . . .
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.



Testing -d64 switch . . .
Sintaxis: java [-options] class [args...]
           (para ejecutar una clase)
   o  java [-options] -jar jarfile [args...]
           (para ejecutar un archivo jar)
donde las opciones incluyen:
    -d32          usar un modelo de datos de 32 bits, si estß disponible
    -d64          usar un modelo de datos de 64 bits, si estß disponible

....

It continue whit more Java commands on spanish, but the deal here was to probe if the switch work and it did. Great!

NOTE: I do have installed Java 7u5 x86/x64; not sure if Java -d32 response means that JVM does not work on my OS or it not recognize my installed version.


RE: JPCSP start .bat says Java not exist due Windows command issue - gid15 - 08-09-2012

I've updated start-windows-x86.bat in r2682 to try to support systems where the REG command is not available. Only changed for the 32-bit Java for now.
Could you test it?


RE: JPCSP start .bat says Java not exist due Windows command issue - montcer9012 - 08-09-2012

I can't cause my OS is x64. But let's wait people use this new batch and see what happen.