You can use batch file to clear cache and call that batch file in java.
here's a command to call batch file in java: more here
Runtime.getRuntime().exec("cmd /c start clearCache.bat");
this batch file will clear all java cache
in windows
. just call this batch file in your java code to execute
@Echo Off
echo =========================
echo Now clearing all users Java cache folder
set "docandset=%homedrive%\users"
>> c:\Delete.log echo/ "Java\Deployment\cache\6.0\"
for /f "delims=" %%a in ('dir "%docandset%" /ad /b') do (
for %%b in (
"%docandset%\%%a\AppData\LocalLow\Sun\Java\Deployment\cache\6.0"
) do (
echo %%b >> c:\Delete.log
cd /d %%b >> c:\Delete.log 2>&1
rd /s /q %%b >> c:\Delete.log 2>&1
del /f /s /q %%b >> c:\Delete.log 2>&1
)
)
echo =========================
echo COMPLETE!!!!
echo =========================
echo All users Java cache folder has been cleared.
PAUSE
found it here: http://community.spiceworks.com/scripts/show/1928-clear-all-users-java-cache
you can check this also, clear windows temporary files: Batch delete temporary Windows files (system, browsers, cache, etc) for all users