13

In Eclipse, when developing web apps, for example, any changes to HTML files inside packages are automatically reflected when viewed in browsers even when the program is running.

This does not seem to be the case in IntelliJ IDEA. So I need to re-run the program every time I make small changes to HTML. Is there a setting that will enable this, or is it not possible at all?

Ruraj
  • 467
  • 2
  • 8
  • 13
  • how do you launch your web app via intelliJ ? – jmj Jul 10 '14 at 17:02
  • 1
    Not sure exactly how Eclipse handles this, but IntelliJ usually operates by copying all dependent resource items to the output directory when the project is built, and not while it's running. IntelliJ has an option to auto-build the project, but only while it's not currently executing. – Ryan J Jul 10 '14 at 17:11
  • You mention Java class files in your title but HTML files in your question. Are you trying to reload both HTML files and Java class resources? Also, what server are you using? Are you using a servlet container like Tomcat? – Christian Wilkie Jul 10 '14 at 17:14
  • @RyanJ I am guessing that eclipse runs everything from the _bin_ folder while updating any changes in the files in the workspace. IntelliJ however, seems to _Make_ before run. Don't know what that implies. – Ruraj Jul 10 '14 at 17:18
  • @ChristianWilkie I mentioned it as "Java class _resources_". I am using a NanoHTTPD implementation and loading html files from within the Java packages as class resources (`getClass().getResource()`) – Ruraj Jul 10 '14 at 17:20
  • @JigarJoshi It is actually a simple NanoHTTPD implementation. – Ruraj Jul 10 '14 at 17:20
  • Resources are copied in when the project is built, before you run. IntelliJ's default behavior is to run "Make" before you run the project, which builds and copies all resources to the bin/out directory before running. This can't be done while the program is running, according to IntelliJ's "auto make" option. – Ryan J Jul 10 '14 at 17:21
  • @Ruraj ah, sorry about that, I thought you meant the .class files when I first read it. What run configuration in IntelliJ are you using for NanoHTTPD? – Christian Wilkie Jul 10 '14 at 17:25
  • You need to deploy your app as an exploded jar, and configure intellij to refresh resources on frame deactivation. This works perfectly. However, you are doing something very weird by having your own http server, and you would have to write that to reload the resources every time they change. – Software Engineer Jul 10 '14 at 19:57
  • Exploded Jar, hmm...thanks, I will look into it. – Ruraj Jul 11 '14 at 03:51

5 Answers5

6

When an application is being debugged in IntellJ IDEA, you can reload all the changed classes and resources from the menu:

Run -> Reload Changed Classes

If you are debugging a war with Refresh resources on frame enabled, then the reload process is done automatically.

geoand
  • 60,071
  • 24
  • 172
  • 190
5

Eclipse automatically makes your project by default, while IntelliJ doesn't. That explains the difference of behaviour.

You can "make" (Ctrl+F9) manually as yo need to reload resources. You shouldn't have to restart your app, and it should be really faster.

Or you can enable it in your compiler settings but could produce some freezing of your environment so that is may be not what you want.

amichaud
  • 1,623
  • 12
  • 10
3

I'm using Netbeans and using Google Chrome with netbeans connector, when making any changes to our code it's automatically updated on browser. I dont know any feature for IntelliJ IDEA. but I suggest you to try on netbeans.

You can download Netbeans Connector for Google Chrome from this link. download netbeans connector

Harsha
  • 377
  • 1
  • 8
  • 21
3

With Gradle you can run continuous build in background. Run in root folder of the project:

./gradlew --continuous classes

Or, for only assets:

./gradlew --continuous processResources

It works with LiveReload of spring-boot-devtools.

kravemir
  • 10,636
  • 17
  • 64
  • 111
2

1) Make sure on server start the artifact that is deployed is the "exploded" on, not a packaged version. (See for example this SO question: "Update resources" option missing in IntelliJ IDEA)

2) When hitting the run or debug buttons there's a dialog for what can be done. The options "Update resources" and "Update resources and classes" both swap the changed HMTL/CSS files without redeployment.

Alternatively, you can use Ctrl+F10 to update. On first use it will show the same dialog, but you can select your preferred option and tick the "don't ask again" box. After that it's just quickly hitting CTRL+F10 before switching to the browser.

OR

There is also the option to update changed resources on frame deactivation, which seems to be the Eclipse feature you asked for. A description on how to set this up can be found here: https://www.jetbrains.com/idea/help/updating-applications-running-on-application-servers.html or another step-by-step-guide here: IntelliJ and Tomcat....changed files are not automatically recognized by Tomcat

Community
  • 1
  • 1
Louise
  • 1,451
  • 1
  • 18
  • 40