Kyro
Kyro

Reputation: 51

How do I clear a specific file in the Java cache?

I would like to remove a specific cached jar file from a Java program. Java cache behaves weirdly sometimes, and keeps loading an old jar even if a new one should be used.

The "Java Control Panel" has a "Java Cache Viewer" feature that allows us to see cached jar files.

The Java Cache Viewer

I was wondering if there was a way to detect a cached jar file but directly from a java program, and then remove that file. Is there an API allowing that?

Upvotes: 2

Views: 4750

Answers (2)

Glenninator
Glenninator

Reputation: 47

Yes! I've just found a solution to this problem. There's a command line statement "javaws" that let's you handle specific java-related actions. You can type javaws into your console/terminal and it'll give you options but to remove a specific application, you could add this to your code:

Runtime.getRuntime().exec("javaws -uninstall <jnlp file>"); 

where can be the file or a url.

Hope this helps!

Upvotes: 2

Related Questions