1

I have a system variable %PORT% what is passed to jvm

JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=%PORT%

I need what every time JAVA_TOOL_OPTIONS is pickup the %PORT% get a new value.

I have the script whats find a free port but I don't know where put it.

@echo off
set freePort=
set startPort=80

:SEARCHPORT
netstat -o -n -a | find "LISTENING" | find ":%startPort% " > NUL
if "%ERRORLEVEL%" equ "0" (
  echo "port unavailable %startPort%"
  set /a startPort +=1
  GOTO :SEARCHPORT
) ELSE (
  echo "port available %startPort%"
  set freePort=%startPort%
  GOTO :FOUNDPORT
)

:FOUNDPORT
echo free %freePort%
4

0 回答 0