To clear the Java cache, open the Java control panel, which you can find in the Windows Control Panel or in System Preferences on a Mac.
To reallocate RAM to "Minecraft," you'll have to edit the game's settings through whatever launcher app you use.