This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JPCSP start .bat says Java not exist due Windows command issue
#1
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.


Attached Files Thumbnail(s)
   
[Image: montcer.png]
Reply
#2
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
Always include a complete log file at INFO level in your reports. Thanks! How to post a log
Reply
#3
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.
[Image: montcer.png]
Reply
#4
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.
Always include a complete log file at INFO level in your reports. Thanks! How to post a log
Reply
#5
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.


Attached Files Thumbnail(s)
   
[Image: montcer.png]
Reply
#6
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?
Always include a complete log file at INFO level in your reports. Thanks! How to post a log
Reply
#7
I can't cause my OS is x64. But let's wait people use this new batch and see what happen.
[Image: montcer.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)