小能豆

卸载 java jre8 并安装 Amazon Corretto jdk11.0.13_8 后 sikuli 执行错误

javascript

有执行脚本,我已将jdk11.0.13_8放置在执行目录中:

@echo off

REM temp fix to avoid using zulu java 10
set JAVA_HOME=%~dp0\jdk11.0.13_8


SETLOCAL ENABLEEXTENSIONS
set SJAR=sikulix

if not defined SIKULIX_HOME goto NOHOME
if EXIST "%SIKULIX_HOME%%SJAR%.jar" goto YESHOME
if not EXIST "%SIKULIX_HOME%\%SJAR%.jar" goto BADHOME
set SJAR=\sikulix

:BADHOME
echo +++ SIKULIX_HOME specified but not useable %SIKULIX_HOME%

:NOHOME
set SIKULIX_HOME=%~dp0

:YESHOME
set PARMS=-Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine

if not defined JAVA_HOME goto CHECKJAVA
IF EXIST "%JAVA_HOME%\bin\java.exe" goto JAVA_OK
echo +++ JAVA_HOME specified but not useable %JAVA_HOME%
echo +++ looking for Java in system path and then in standard places

:CHECKJAVA
java 2> nul
if errorlevel 9009 goto CHECKPLACES
goto JAVA_OK_PATH

:CHECKPLACES
set PROGRAMS=%ProgramFiles%
if defined ProgramFiles(x86) set PROGRAMS32=%ProgramFiles(x86)%

IF not EXIST "%PROGRAMS%\Java\jre8\bin\java.exe" goto JAVA7
set JAVA_HOME=%PROGRAMS%\Java\jre8
goto JAVA_OK

:JAVA7
IF not EXIST "%PROGRAMS%\Java\jre7\bin\java.exe" goto JAVA6
set JAVA_HOME=%PROGRAMS%\Java\jre7
goto JAVA_OK

:JAVA6
IF not EXIST "%PROGRAMS%\Java\jre6\bin\java.exe" goto JAVANO
set JAVA_HOME=%PROGRAMS%\Java\jre6
goto JAVA_OK

:JAVANO
if not defined PROGRAMS32 goto JAVANO32

IF not EXIST "%PROGRAMS32%\Java\jre8\bin\java.exe" goto JAVA732
set JAVA_HOME=%PROGRAMS32%\Java\jre8
goto JAVA_OK

:JAVA732
IF not EXIST "%PROGRAMS32%\Java\jre7\bin\java.exe" goto JAVA632
set JAVA_HOME=%PROGRAMS32%\Java\jre7
goto JAVA_OK

:JAVA632
IF not EXIST "%PROGRAMS32%\Java\jre6\bin\java.exe" goto JAVANO32
set JAVA_HOME=%PROGRAMS32%\Java\jre6
goto JAVA_OK

:JAVANO32
echo +++ Java not found in standard places %PROGRAMS% or %PROGRAMS32%
echo +++ JAVA_HOME not specified
goto STOPIT

:JAVA_OK_PATH
echo +++ running this Java
set SIKULI_COMMAND=%*
java -version
PATH=%SIKULIX_HOME%libs;%PATH%
echo +++ trying to run SikuliX
echo +++ using: %PARMS% -jar %SIKULIX_HOME%%SJAR%.jar %SIKULI_COMMAND%
java %PARMS% -jar "%SIKULIX_HOME%%SJAR%.jar" %SIKULI_COMMAND%
GOTO FINALLY

:JAVA_OK
echo +++ running this Java
set SIKULI_COMMAND=%*
"%JAVA_HOME%\bin\java.exe" -version
PATH=%SIKULIX_HOME%libs;%PATH%
echo +++ trying to run SikuliX
echo +++ using: %PARMS% -jar %SIKULIX_HOME%%SJAR%.jar %SIKULI_COMMAND%
"%JAVA_HOME%\bin\java.exe" %PARMS% -jar "%SIKULIX_HOME%%SJAR%.jar" %SIKULI_COMMAND%
GOTO FINALLY

:STOPIT
echo.+++ ended with some errors
:FINALLY
ENDLOCAL

我在cmd中执行该文件,错误:

C:\SikuliX>runsikulix.cmd
+++ running this Java
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment Corretto-11.0.13.8.1 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.13.8.1 (build 11.0.13+8-LTS, mixed mode)
+++ trying to run SikuliX
+++ using: -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine -jar C:\SikuliX\sikulix.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.sikuli.basics.Debug.log(Debug.java:697)
        at org.sikuli.basics.Debug.logx(Debug.java:675)
        at org.sikuli.script.RunTime.log(RunTime.java:99)
        at org.sikuli.script.RunTime.get(RunTime.java:184)
        at org.sikuli.ide.SikuliIDE.run(SikuliIDE.java:177)
        at org.sikuli.ide.Sikulix.main(Sikulix.java:21)
Caused by: java.lang.NumberFormatException: For input string: "."
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:638)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at org.sikuli.basics.Settings.<clinit>(Settings.java:123)
        ... 6 more

阅读 58

收藏
2023-11-20

共1个答案

小能豆

这个错误似乎是由于在Settings.java文件的静态初始化块中,尝试将字符串”.”解析为整数时引起的。在你的错误日志中,这个问题发生在以下部分:

Caused by: java.lang.NumberFormatException: For input string: "."
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:638)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at org.sikuli.basics.Settings.<clinit>(Settings.java:123)

Settings.java 的 123 行,似乎有一个字符串无法被正确解析为整数。可能的原因是,该设置可能在代码中期望一个整数值,但实际上包含了一个非法的字符。

要解决这个问题,你可以尝试以下几步:

  1. 打开 Settings.java 文件,找到第 123 行,并检查相关的代码,看看哪里使用了一个可能导致 NumberFormatException 的字符串。
  2. 如果可能,尝试将该字符串转换为一个有效的整数值,或者确保该字符串包含一个有效的数字。
  3. 如果你不清楚如何修复问题,你可以在这里提供 Settings.java 文件中相关部分的代码,我可以帮助你检查并提供一些建议。
  4. 确保 SikuliX 版本与 Java 版本兼容。某些 SikuliX 版本可能对特定的 Java 版本有要求。

注意:在更改代码之前,请确保在修改之前对其进行备份,以免出现不可预料的问题。

2023-11-20