Clear Java Cache

2019-06-21 20:08发布

I want to know how you can clear your Java Cache using Java Code or CMD Line code.

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.

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.

标签: java caching
3条回答
淡お忘
2楼-- · 2019-06-21 20:17

This can be archived by following line: javaws -Xclearcache -silent -Xnosplash

查看更多
Viruses.
3楼-- · 2019-06-21 20:23

My understanding is that there are three mainstream Java caching technologies:

  1. There is the Application Cache that is part of Java Webstart and associated browser plugins. This can be controlled using the javaws command-line tool, or the Java Control Panel, as outlined in @RuchiraGayanRanaweera's answer.

    AFAIK, javaws is the only supported way to control the application cache from the command line.

  2. There is the Java Object Cache framework that is part of Oracle's J2EE container product line (aka OC4J). This is described in the OC4J documentation: "Chapter 9 - Java Object Cache". (I don't think this is what you are looking for.)

  3. Some JVM implementations have a feature that allows compiled classes to be cached and shared or reused by different JVMs. IBM Java and Eclipse OpenJ9 support this; e.g. see "Shared class cache".

    However, this is not a supported feature of standard (free) Oracle or OpenJDK Java. There is / was apparently an obscure JVM feature for sharing system class data that was introduced in Java 5, and a commercial feature exists (since Java 8) to extend this to application classes. Details are hard to find ...

UPDATE - As of Java 10, Oracle and OpenJDK JVMs now support "Class Data Sharing" (CDS). This document has instructions on how to regenerate the cache from the command line.


Given the context in which the question was originally asked, I suspect that the OP is (was) actually asking about Java Webstart application caching, but didn't realize that this functionality is part of Java Webstart rather than Java SE as a whole.

查看更多
冷血范
4楼-- · 2019-06-21 20:29

You can do it using Java Control Panel.

How do I clear the Java cache?

How can do it in command line?

This will be the command to clear cache

javaws -clearcache // Remove all non-installed applications from the cache.

And

javaws -uninstall // Remove all applications from the cache.
查看更多
登录 后发表回答