清除Java缓存 [英] Clear Java Cache
问题描述
我想知道如何使用Java代码或CMD Line代码清除Java缓存。
I want to know how you can clear your Java Cache using Java Code or CMD Line code.
此操作应在Windows 7或更高版本的Microsoft Windows计算机上完成。
This should be done on a Microsoft Windows Machine anywhere from Windows 7 up.
此操作应在多台计算机,因此文件路径会有所不同。
This should be done on multiple computers so the file paths will be different.
该应用程序使用Javaw作为启动时的默认应用程序(不要与Javaws或Webstart混淆-我已经拥有了代码如何清除Javaws缓存)。因此,我将需要知道如何清除Javaw缓存。
The application uses Javaw as it's default application that it launches with (Not to be confused with Javaws or Webstart - I already have code how to clear Javaws cache). So I will need to know how to clear Javaw cache.
推荐答案
创建一个名为clearCache.bat的批处理文件。
create a batch file named clearCache.bat.
@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
现在从命令提示符(cmd)运行批处理文件
now from command prompt(cmd) run the batch file
Runtime.getRuntime().exec("cmd /c start clearCache.bat");
它会在清除缓存后向您显示警报。
it will show you an alert after clearing the cache.
这篇关于清除Java缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!