jasypt in cmd: cannot find main class

WesternGun picture WesternGun · Nov 20, 2015 · Viewed 7.4k times · Source

I am using jasypt 1.9.2 in Windows 7 x64 cmd. Here's encrypt.bat content:

ECHO ON


set SCRIPT_NAME=encrypt.bat
set EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI
set EXEC_CLASSPATH=.
if "%JASYPT_CLASSPATH%" == "" goto computeclasspath
set EXEC_CLASSPATH=%EXEC_CLASSPATH%;%JASYPT_CLASSPATH%

:computeclasspath
IF "%OS%" == "Windows_NT" setlocal ENABLEDELAYEDEXPANSION
FOR %%c in (%~dp0lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%%c
IF "%OS%" == "Windows_NT" setlocal DISABLEDELAYEDEXPANSION

set JAVA_EXECUTABLE=java
if "%JAVA_HOME%" == "" goto execute
set JAVA_EXECUTABLE="%JAVA_HOME%\bin\java"


:execute
%JAVA_EXECUTABLE% -classpath %EXEC_CLASSPATH% %EXECUTABLE_CLASS% %SCRIPT_NAME% %*

I got this error(I also tried cd /d [the dir where encrypt.bat is located] and the error persists):

enter image description here

The error message points out that the main class of org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI is no where to be found. I don't understand this. I tried to change JAVA_HOME value in system variables and no luck.

Answer

WesternGun picture WesternGun · Feb 17, 2016

I finally downloaded again the original release and it works. Seems that I messed something up when I was trying to edit the encrypt.bat... I noticed this difference:

With @echo on, I see this output in working version:

C:\Users\myname>FOR %c in (C:\Users\myname\Documents\[APP]\jasypt-1.9.2-dist_new\bin\..\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%c

And in my answer I see this:

C:\Users\myname>FOR %c in (C:\Users\myname\Documents\[APP]\jasypt-1.9.2-dist_new\bin\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%c 

Note the .. before lib.

Also: don't put jaspyt in some path with space! It also cause error, even with quotes.