Programming

How to Clear Java Cache: Windows, Mac, Command Line and Code

Noah, an operations manager at a logistics company we support, called us because an old internal Java app had stopped launching on half the office computers. The vendor had pushed an update, but the machines kept loading the previous version from their local Java cache. Clearing that cache on each computer took two minutes, and the app opened normally again. We see the same problem every few months with legacy Java Web Start tools, signed applets and enterprise portals.

perations manager clearing Java cache in the Java Control Panel on an office computer Caption: Clearing Java cache fixes old app versions loading after an update.

To clear Java cache, you delete the temporary files that Java stores for downloaded apps, either through the Java Control Panel, the javaws command or by deleting the cache folder. But “Java cache” means different things to different people. A desktop user means the deployment cache. A developer may mean an in-memory cache in their own code, a Spring cache, a Selenium browser session or even the browser cache behind JavaScript. Each one clears differently, so the sections below handle each case, starting with the one most people need.

Quick answer: To clear Java cache on Windows or Mac, open the Java Control Panel, go to the General tab, click Settings under Temporary Internet Files, then click Delete Files and confirm. From the command line, run javaws -clearcache. In Java code, call clear() on your map or invalidateAll() on a Caffeine or Guava cache.

What Is the Java Cache?

The Java cache is a folder where Java stores files it downloaded to run Java Web Start apps and applets, such as JAR files, JNLP files and certificates. Java keeps them so apps start faster next time. When those files go stale or get corrupted, apps fail to launch, show old versions or throw errors.

When You Should Clear Java Cache

  • A Java app keeps loading an old version after an update.
  • You see errors such as “Unable to launch the application” or “Could not load file or URL”.
  • A certificate or security warning keeps repeating.
  • An internal tool or portal behaves differently on one computer than on others.
  • IT asks you to clear it as a first troubleshooting step.

Java Cache vs Other Caches

Cache typeWhat it storesHow to clear it
Java deployment cacheDownloaded JAR, JNLP and certificate filesJava Control Panel or javaws -clearcache
In-memory cache in codeObjects your program stores for reuseclear() or invalidateAll() in code
Spring cacheMethod results cached by the framework@CacheEvict or CacheManager
Browser cacheWeb pages, scripts and imagesBrowser settings or Clear-Site-Data header
Build tool cacheMaven and Gradle dependenciesDelete .m2 or .gradle cache folders
Different types of Java cache and how to clear each one

How to Clear Java Cache on Windows 10 and Windows 11

On Windows 10 and Windows 11, the fastest way to clear Java cache is through the Java Control Panel. It is installed with Java 8 and older runtimes that include the browser plugin and Web Start. The steps are the same on both Windows versions, and the whole process takes under a minute.

Steps in the Java Control Panel

  1. Open the Start menu and search for Configure Java, or open Control Panel and click Java.
  2. On the General tab, find Temporary Internet Files and click Settings.
  3. Click Delete Files.
  4. Tick Trace and Log Files, Cached Applications and Applets and, if you want a full reset, Installed Applications and Applets.
  5. Click OK, then OK again, and restart the app or browser.

If You Can’t Find the Java Control Panel

Newer Java versions, from Java 11 onward, no longer ship the browser plugin, Web Start or the Java Control Panel. If you only have a modern JDK, there is no deployment cache to clear. If an app needs Web Start, your vendor may supply its own launcher, such as OpenWebStart, which has its own cache settings.

How to Clear Java Cache on Mac

On a Mac, you clear Java cache through the Java icon in System Settings. The steps match Windows once the Java Control Panel opens. Mac users of older enterprise apps hit this most often after a macOS update, because security changes can leave stale certificates in the cache.

Steps on macOS

  1. Open System Settings (or System Preferences on older macOS).
  2. Click the Java icon at the bottom to open the Java Control Panel.
  3. On the General tab, click Settings under Temporary Internet Files.
  4. Click Delete Files, tick the items you want removed and click OK.

Clear It From Terminal

If the Control Panel won’t open, delete the cache folder directly:

rm -rf ~/Library/Application\ Support/Oracle/Java/Deployment/cache

Close any running Java apps first, then relaunch them.

Clear Java Cache From the Command Line

The javaws tool lets you clear Java cache from the command line, which helps when you need to script it across many computers. According to the Oracle javaws reference, -clearcache removes all non-installed applications, while -uninstall removes every application from the cache.

javaws Commands

javaws -clearcache          (removes non-installed apps from the cache)
javaws -uninstall           (removes all apps from the cache)
javaws -uninstall myapp.jnlp (removes one app)
javaws -viewer              (opens the cache viewer)

A Simple Clear Java Cache Script for Windows

IT teams often ask us for a clear Java cache script they can push to every machine. This batch file runs javaws and then deletes the cache folder for the current user:

@echo off
javaws -uninstall
rmdir /s /q "%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\cache"
echo Java cache cleared

Run it while Java apps are closed. On shared computers, run it for each user profile.

Java Cache Location on Windows, Mac and Linux

Knowing the Java cache location helps when the Control Panel is broken or when you want to delete the files by hand. The cache lives inside each user’s profile, so every user on a shared computer has their own copy. Delete the cache folder only, not the whole Deployment folder, unless you also want to reset Java settings.

Default Cache Folders

Operating systemJava cache location
Windows 10 and 11%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\cache
macOS~/Library/Application Support/Oracle/Java/Deployment/cache
Linux~/.java/deployment/cache
Default Java cache location by operating system

Check the Location in the Control Panel

Open the Java Control Panel, click Settings under Temporary Internet Files and look at Location. If your company changed the default, the real path shows here. You can also lower the disk space Java may use for its cache on the same screen.

How to Clear Cache in Java Code

If you are a developer asking how to clear cache in Java code, you mean an in-memory cache inside your application. Clearing it is usually one method call. The exact method depends on whether you use a plain map, a caching library like Caffeine or Guava, or a framework such as Spring.

Clearing a Simple Map Cache

import java.util.concurrent.ConcurrentHashMap;

ConcurrentHashMap<String, User> userCache = new ConcurrentHashMap<>();
userCache.remove("user-42"); // remove one entry
userCache.clear();           // empty the whole cache

Clearing a Caffeine or Guava Cache

Caffeine is the most popular Java cache library today, and Guava’s cache has a very similar API:

Cache<String, User> cache = Caffeine.newBuilder()
        .maximumSize(10_000)
        .build();

cache.invalidate("user-42"); // remove one key
cache.invalidateAll();       // clear everything

Clearing a Spring Cache

In Spring, use @CacheEvict on a method, or clear a cache through the CacheManager. The Spring cache abstraction docs explain each option:

@CacheEvict(value = "users", allEntries = true)
public void refreshUsers() { }

// or programmatically
cacheManager.getCache("users").clear();

How to Clear Cache in a Java Application Server

For a full Java application, restarting the service clears in-memory caches, but it also causes downtime. A better approach is an admin endpoint or a scheduled job that calls the eviction methods above. If you run Java on Linux servers, our guide to checking your Ubuntu version helps when you match runtime packages to the OS.

Clear Cache in Selenium Java and SAP Java

Two other common searches are how to clear cache in Selenium Java and how to clear cache in SAP Java. Both are really about browser or server caches that a Java tool controls. The fix is different for each, so handle them separately from the desktop Java cache.

Selenium With Java

Each new WebDriver session usually starts with a fresh browser profile, which is the cleanest way to avoid cache problems. To clear cookies inside a session, use the method from the Selenium cookies documentation:

driver.manage().deleteAllCookies();

For Chrome, you can also clear the browser cache through the DevTools protocol in Selenium 4, or start Chrome in incognito mode with ChromeOptions.

SAP Java (NetWeaver)

In SAP NetWeaver Portal, administrators can clear portal caches such as the navigation cache from the System Administration area. End users of SAP web apps should first clear their browser cache and, for older SAP tools that run as Java applets, the Java deployment cache using the steps above.

How to Clear Cache in JavaScript

JavaScript is a different language from Java, but many people search for both. JavaScript cannot wipe the browser cache directly for security reasons. Instead, you control caching with headers, cache busting and the Cache API. These options let you force fresh files without asking users to clear their browser.

JavaScript Clear Cache Without Reload

// Delete Cache API storage (used by service workers)
caches.keys().then(keys => keys.forEach(key => caches.delete(key)));

// Bust the cache for one file by adding a version
fetch('/data.json?v=2');

Force the Browser to Clear Cache Programmatically

Send the Clear-Site-Data header from your server to tell the browser to remove cached data for your site. For Chrome users who need a manual fix, the same steps from our guide on fixing a 400 Bad Request error apply: clear site data, then hard reload. jQuery has no separate cache to clear, so the same methods apply there too.

Clear Cache on Your Computer, Chrome and Android

  • Chrome: Settings, then Privacy and security, then Delete browsing data.
  • Android: Settings, then Apps, pick the app, Storage, then Clear cache.
  • Windows computer: run Disk Cleanup and tick Temporary files.

Clear Java Cache for Minecraft Java Edition

Minecraft Java Edition runs on Java, so players often search for how to clear Minecraft cache in Java. Most launch and loading problems come from the game folder rather than the Java deployment cache. Back up your worlds before deleting anything, because some folders hold saves and settings.

Safe Steps for Minecraft

  1. Close the game and the launcher.
  2. Open the .minecraft folder (press Win + R and type %appdata%\.minecraft on Windows).
  3. Copy the saves folder somewhere safe.
  4. Delete temporary folders such as logs and crash-reports, and the webcache folder in the launcher data if it exists.
  5. Reopen the launcher and let it download fresh files.

Clear Build Caches for Java Developers

Developers who build Java apps can also clear dependency caches when builds act strangely. Delete ~/.m2/repository for Maven or ~/.gradle/caches for Gradle, then rebuild. Expect the first build to take longer while dependencies download again.

FAQs

These are the most common questions about clearing Java cache.

How do I clear Java cache on Windows 11?

Search for Configure Java in the Start menu to open the Java Control Panel. On the General tab, click Settings under Temporary Internet Files, then click Delete Files, tick the cached applications and trace files and click OK. Restart the app afterward. If Configure Java does not appear, you may only have a newer Java version that has no deployment cache at all.

What is the command to clear Java cache?

Run javaws -clearcache to remove all non-installed applications from the Java cache, or javaws -uninstall to remove every application. You can also delete the cache folder directly with a script. On Windows the folder sits under AppData LocalLow Sun Java Deployment cache. Close running Java apps before you run any of these commands so files are not locked, and run them for each user on shared computers.

Where is the Java cache located?

On Windows, the Java cache sits in the user profile under AppData, LocalLow, Sun, Java, Deployment, cache. On macOS it is in Library, Application Support, Oracle, Java, Deployment, cache inside your home folder. On Linux it is the .java deployment cache folder in your home directory. The Java Control Panel shows the exact location under Temporary Internet Files settings if your company changed it.

Is it safe to clear Java cache?

Yes. Clearing Java cache only removes temporary files that Java downloaded to run apps faster. Java downloads fresh copies the next time you launch each app, so the first launch may take a little longer. If you also delete installed applications, you may need to reinstall shortcuts for some Web Start apps from your vendor or IT team, so check with them first.

How do I clear cache in Java code?

It depends on how you cache data. For a HashMap or ConcurrentHashMap, call clear() or remove a single key. For Caffeine or Guava, call invalidateAll() or invalidate() for one key. In Spring, add @CacheEvict with allEntries set to true, or call clear() on the cache from the CacheManager. Choose targeted eviction where you can, because clearing everything at once can cause slow cold starts under load.

How do I clear cache in Selenium Java?

The cleanest method is to start each test with a new WebDriver session, which uses a fresh browser profile. Inside a session, call driver.manage().deleteAllCookies() to remove cookies. For Chrome, Selenium 4 also lets you clear the browser cache through the DevTools protocol, or you can run the browser in incognito mode through ChromeOptions for each test run to keep results clean and repeatable.

Do newer Java versions still have a cache to clear?

Java 11 and later removed the browser plugin, Java Web Start and the Java Control Panel, so there is no deployment cache to clear in a plain modern JDK. If your company still runs Web Start apps, it may use OpenWebStart or a vendor launcher with its own cache settings. Developers still have Maven and Gradle caches, which can be cleared separately.

Is clearing Java cache the same as clearing browser cache?

No. Java cache holds files for Java apps and applets, while browser cache holds web pages, images and scripts. Clearing one does not clear the other. If a web app that uses Java fails, clear both: the browser cache through your browser settings and the Java cache through the Java Control Panel. Then restart the browser fully before testing the app again.

Conclusion

To clear Java cache, start with the Java Control Panel on Windows or Mac, or run javaws -clearcache when you need a script for many machines. If the Control Panel is missing, delete the cache folder from the user profile, or check whether a modern Java version is in use and there is no deployment cache at all. For developers, clearing a cache is usually one call in code, whether you use a map, Caffeine, Guava or Spring.

Noah’s team now runs a small clear Java cache script whenever the vendor ships an update, and the “old version” tickets stopped. Match the method to the cache you actually have, and you will fix most problems in minutes. If your company is planning to modernize old Java tools, our post on the benefits of outsourcing Java development covers what to look for in a partner, and capturing a HAR file from your browser helps when web issues persist. Which type of Java cache are you trying to clear?

Leave a Reply

Your email address will not be published. Required fields are marked *

Share the article

Written By

Author Avatar

November 11, 2026

Hi there! I’m Ayesha Khan, a skilled content writer with a strong background in computer science. I specialize in transforming complex ideas into clear, engaging, and easy-to-understand content. With 10 years of experience working across different industries, I focus on delivering content that not only informs but also connects with readers. I’m passionate about writing and take pride in creating high-quality work that helps clients communicate their message effectively.