Search code examples
javaintellij-ideahotswap

Howswap resources with IDEA


I develop a simple standalone application without any application server. Can IDEA do hotswap with resources (hotswap works with classes fine when I do rebuild). Also I use gradle as a build system, my application read static resources from "src/main/resources". I just want that when I do rebuild my application could download newer version of my resouce file without restart.

I use this code to read resources:

Thread.currentThread().getContextClassLoader().getResourceAsStream(name)

Solution

  • Yes, IDEA hotswaps changes made to file. You have 2 options:

    • right click on resource and select "Compile '[resource name]'"
    • go to "Gradle" pane and run "Project > Tasks > build > assemble"

    Both of them will pick up resource changes and make them available with no need to restart Debug session.