I didn't say you have too many quotes, i said you are missing one - more specifically the end quote.

SHELL '%COMSPEC% /e:1024 /c "dir /b /ad /o-n %ProgramFiles%\Java\ >> c:\JavaDirectory.txt"'

Probably won't solve your problem, but should be fixed anyway.