Vous pouvez également effectuer les opérations suivantes:
- copiez le fichier bat ci-dessous dans n'importe quel dossier déjà présent dans votre
PATH
variable d'environnement
- puis utilisez simplement la
keytool
commande dans n'importe quel shell Windows
L'emplacement réel de keytool est défini dans le fichier bat. Si l'emplacement est erroné, le fichier bat analysera votre système pour détecter les emplacements potentiels dans les (sous) dossiers ProgramFiles.
Trouvez également keytool2.bat, un raccourci pratique pour "keytool -v -list -keystore", qui est largement utilisé pour vérifier rapidement le contenu d'un fichier jks.
keytool.bat:
::
::
:: "keytool alias" script by Céphas
:: easy method : add the known keytool.exe folder to your personal PATH variable (run : C:\Windows\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables)
:: else, add the folder containing this bat script to your personal path or put this script in any folder already defined in your path
::
:: also see keytool2.bat that automatically adds the following parameters in the keytool command line : -v -list -keystore, for quick display of jks content
::
::
@echo off
set THIS_SCRIPT=%~f0
rem setlocal enableDelayedExpansion : necessary for paths containing special chars
setlocal enableDelayedExpansion
rem set PATH to keytool.exe ; path must include the final \
rem ^ is escape char for paths containing & \ < > ^ |
set PATH_TO=C:\Program Files\Java\jre1.8.0_45\bin\
set PROG_NAME=keytool.exe
rem full_path, with "", to work with paths containing special chars
set FULL_KT_PATH="!PATH_TO!!PROG_NAME!"
rem checks if keytool.exe exists
(dir %FULL_KT_PATH%>nul 2>nul && set KT_FOUND=yes) || set KT_FOUND=no
if %KT_FOUND%==yes (
rem keytool found => launching it with all supplied parameters
rem
rem
%FULL_KT_PATH% %*
rem
rem
) else (
rem keytool not found, trying to find it in %ProgramFiles%
echo.
echo Keytool not found in expected location, scan in progess ...
echo.
cd "%ProgramFiles(x86)%" 2>nul && dir /B /S keytool.exe 2>nul
cd "%ProgramFiles%" 2>nul && dir /B /S keytool.exe 2>nul
echo.
echo *********
echo Path to program keytool.exe not properly defined, or keytool/java missing on this system
echo If any location has been found during above scan, fix variable "PATH_TO" in %THIS_SCRIPT% accordingly
echo *********
echo.
pause
)
keytool2.bat:
::
::
:: "keytool2 alias" script by Céphas
:: easy method : add the known keytool.exe folder to your personal PATH variable (run : C:\Windows\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables)
:: else, add the folder containing this bat script to your personal path or put this script in any folder already defined in your path
::
:: keytool2 automatically adds the following parameters in the keytool command line : -v -list -keystore
:: thus, to quickly display the full content of a jks file, usage is simply : keytool2 \path\to\your\keystore.jks [-alias your_alias]
::
::
@echo off
set THIS_SCRIPT=%~f0
rem setlocal enableDelayedExpansion : necessary for paths containing special chars
setlocal enableDelayedExpansion
rem set PATH to keytool.exe ; path must include the final \
rem ^ is escape char for paths containing & \ < > ^ |
set PATH_TO=C:\Program Files\Java\jre1.8.0_45\bin\
set PROG_NAME=keytool.exe
rem full_path, with "", to work with paths containing special chars
set FULL_KT_PATH="!PATH_TO!!PROG_NAME!"
rem checks if keytool.exe exists
(dir %FULL_KT_PATH%>nul 2>nul && set KT_FOUND=yes) || set KT_FOUND=no
if %KT_FOUND%==yes (
rem keytool found => launching it with all supplied parameters
rem
rem
%FULL_KT_PATH% -v -list -keystore %*
rem
rem
) else (
rem keytool not found, trying to find it in %ProgramFiles%
echo.
echo Keytool not found in expected location, scan in progess ...
echo.
cd "%ProgramFiles(x86)%" 2>nul && dir /B /S keytool.exe 2>nul
cd "%ProgramFiles%" 2>nul && dir /B /S keytool.exe 2>nul
echo.
echo *********
echo Path to program keytool.exe not properly defined, or keytool/java missing on this system
echo If any location has been found during above scan, fix variable "PATH_TO" in %THIS_SCRIPT% accordingly
echo *********
echo.
pause
)
/usr/local/java/bin# ./keytool
si vous exécutez Windowsfind the JDK install path and check bin folder