How to enable hot swap in intelliJ - intellij-idea

I want to work on intelliJ on my webapps and I don't know how to hot swap code while working.
For example while I was working in Eclipse when I edited jsp files Eclipse automatically, instantly swapped the file so when I refreshed the page my changes were there
When I change class code in Eclipse it worked a bit longer because he republished the app but did it automatically and instantly.
I saw that intelliJ in the runtime configuration has an option 'how class swap'. I did check it but nothing is happening. I had tried compile, make, save and everything else and nothing is happening. I had to reload the app and I had to do dis manually. Secondly intelliJ reloads EVERY application in my webapp directory. I have them a lot so it taking ages. how can I turn on hot swap?

Hotswap only works in debug mode. So you need to connect to your webserver through a debug configuration. Then, after compile either the project or at least the class with the modifications, IntelliJ tries to hotswap that class.
This only works for minor changes. For example, creating new methods on the fly is not possible using this way.

Hotswap works with exploded artifacts on Update action. If it doesn't work with your project, contact support for help and provide the project to reproduce it.

Related

Getting set up with intelliJ IDEA

Really basic question here but this has always stopped me from using any JetBrains product, but here I am trying once again. I also have the same issues with CLion but that will be for another time and hopefully I can figure it out based on some feedback from this post.
I need to set up my environment in IntelliJ. Nothing special. No build tools. Currently I just run my school projects using
javac Main.java
java Main
This has gotten me so far but I really want to use IntelliJ tools to their full capacity.
I want to be able to set break points and step in and out of my code in their debugger and all the other nice tools that come with running my code through IntelliJ
Every get started tutorial that I have watched on YouTube or from JetBrains themselves already has a basic build configuration set up to run your basic "Hello World" application and that is what I think I need. Just compile my java files into classes and run/debug them.
This is what the run configuration icon in the IDE should look like
And this is what mine currently looks like
I have set many different JDKs to go along with my projects but none of them seem to get the tools I need set up in the IDE. I have even let IntelliJ download one for me and set it up itself to see if maybe I downloaded and installed it wrong and IntelliJ maybe wasn't recognizing it.
This picture below is showing the project structure for an application that I let IntelliJ download a JDK for and set it up itself
So if someone could help me that would be fantastic. Links to videos, blogs are welcome even though I know that isn't the convention on this forum but I think that would be sufficient for my situation. Thanks in advance!
---Update---
I have found that if I create a project in IntelliJ that I get all the default configurations that I need. The problem is when I need to get a project from VCS that I am not getting any of the configurations that I need to run/debug my program in IntelliJ.
The easiest solution here would be to click the green play button next to your main method, on the left where line numbers are displayed.
Intellij will configure a default java run configuration for you. It will be displayed in the menu for later use, like in the screenshot you posted, after your first run.
You can also create one using the to menu: Run > Edit run configuration to add some more options like arguments, environment variables (that only apply for the run config), etc.
A good starting point would be the Intellij help page on that topic. This help pages are always a good start and you find comprehensible instructions there on every topic.
Another good resource is the Intellij by JetBrains YouTube channel. This video about debugging shows both ways I described above. They have lots of quick tutorials about lot of features, like code generation or build tools. Check out the channel's playlists for specific topics.
Update
The problem with the already created project is that the default/ folder is not marked as source folder. You can do that by File > 'Project Structure...' and set the default/ folder as Sources:
The cause for intellij not recognizing this is because you didn't use a folder structure like the one of maven.
For source code:
src/main/java
src/main/resources
and for tests:
src/test/java
src/test/resources
If you set it up that way IntelliJ everything works as expected. I created a pull request to your repo. If you check out the branch, IntelliJ will setup everything correctly automatically.

Launch Grails 3 app from IntelliJ w/ auto-reloading enabled

It looks like IntelliJ's (Ultimate EAP 15) support for Grails 3 is in the early stages yet. If I do Run -> Debug 'Grails:My App', I'm able to launch an app from inside IntelliJ, I can set breakpoints and it works as expected.
If I make changes however, I see in the console that the file is recompiled, but when I hit reload in the browser, I don't see the changes reflected there. I have to stop and restart the app in IntelliJ before I see them. Anyone know how I can get the auto-reloading working?
After chasing this for a week, this post finally provided an explanation.
It's actually a Grails issue, not a problem with IntelliJ's Grails integration: spaces in a file's path will break automatic reloading. Renaming my project from Grails Demo to GrailsDemo got everything straighted out. (Storing a project in a folder like My Documents will also cause trouble.) The post's author indicates that this started with version 2.4.4 and it's still happening for me in 3.0.4.

asset library (swc) does not reflect changes in flash project in fb

I have created gui related components in flash professional and exported the swc and added this swc into my referenced libraries (by adding link to the swc) and I can create/reference to the symbols in my flash builder project.
Every thing is fine untill I modify something(MC) and export the swc the changes won't reflect immediately. This is somewhat understood, so I just use to restart FB so that the changes are reflected. This was working find until yesterday.
After making changes to symbols, nothing will reflect the changes
I restart the FB (which use to work till yesterday)
Refresh project, referenced libraries
Clear browser cache
Clean the project
I left home with frustration and today morning when I restarted the system it got reflected the changes. And now I did changes to the gui again and its the same problem.
I know there is one easy way which is to remove and add the swc reference from the project
I am pretty sure there could be much easy simple way to do it.
The compiler cache can sometimes not pick changes in SWC libraries (old known issue).
Solution, when you think this problem happens, is to "clean" the project. Both FlashBuilder and FlashDevelop let you clean the project from the Project main menu.

PlayFramework2 required Jar files and recognising compiled sources

Finding hard to know why am I unable to get this thing :
... I can run my application from command prompt, But when I do idea and Import the existing project using IntelliJ unable to trace out what Libraries or Jar files I need to get going.
In one Play1.2.3 I used to just Import Play and Play1.2.3 jar files and everything works..
Update
Have tried Creating a new project and Open Project(Instead of Import) from IntelliJ,But no luck.It has attached all the Libraries but still the error doesnt go screenshot attached:
IDE :IntelliJ 11.0.2 &
Play : 2.0.2
Since Play 2.0.2 you don't need to create Idea's project from the scratch and import modules into it.
Just choose Open project from the menu, and find the folder where you performed play idea action, whole project will be ready to use in the IDE without any additional steps.
Edit:
Most important: to reflect changes in managed sources your application need to compile it first, so it needs to work in the background while developing or you need to compile it manually if app is stopped. Otherwise Idea will not be able to compile (and find) managed sources. That's exactly job of the Play's DEV mode which differs from others Java frameworks, which requires to compile app manually and/or configuring your IDE to do that from time to time. Play's dev mode allows to do it in background.
Idea will start recognizing your managed sources after first run the app in the browser (as it will compile it, and idea will catch it just few seconds later). Of course the app must be running in dev mode, to compile views, assets etc.
play run
Of course if you're in production mode, you also need to restart the app.
alternatively after idealizing the project, or if your app is not working you can manually compile managed sources with:
play compile
Also if you'll start in tilde-dev mode, it will be compiling changed resources right after the changes' saving
play ~run

How to enable hot swapping in debug mode with gradle and jetty?

I'm using jettyRun for running my simple spring application. I wanted to enable hot swapping with Intellij debuger, but looks like jetty doesn't catch the changes.
On http://docs.codehaus.org/display/GRADLE/Gradle+Jetty+Plugin I seen that it should work with:
jettyRun.scanIntervalSeconds=1
On the other hand, there is some inconsistency. On the gradle homepage this parameter is not listed: http://www.gradle.org/jetty_plugin. Anyway, is there any way to enable this on gradle?
Heh, actually found it myself now.
Looks like this parameter is not needed at all. Hot deploy works anyway.
I just wasn't able to seen that because my vaadin application was keeping session even after F5. To restart it properly it's enough to add ?debug&restartApplication to the application url.
So, Ctrl+Shift+F9 in IntelliJ + F5 in the browser (with ?debug&restartApplication) works fine ;)