I'm developing an Eclipse plugin, and I test it launching a secondary Eclipse instance using Run As -> Eclipse Application in my project.
So far so good. However, every time I make a source code change (in Java) I need to close this secondary Eclipse instance and start it again to see my code changes being run.
Do you know of any hot deploy option for an Eclipse plugin? It would save me time since Eclipse is slow to load back again and again.
I guess I got used to Tomcat that implements hot deploy. The moment you save your Java source file Tomcat automatically deploys it behind the scenes. It doesn't deploy the whole application, but just the modified class -- something that takes just a few milliseconds.
Using "Debug" instead of "Run" should be enough.
If this doesn't work, check in the Preferences in Java > Debug that "Enable hot code replace" is on.
Also make sure that "Build Automatically" is selected in the "Project" menu. (Or manually invoke "Build" after saving)
Related
Please I am using plug-in development tool in Eclipse. I run my plug-in like that: Run=> Run as=> Eclipse application another ide for execution opend and I see result, but when i change the code in my IDE of plug-in development I need to close the execution application and run again to see the new result.
I want to modify in the IDE and keep see the new changes in the runtime-EclipseApplication there is way please to that ? thanks .
Debug=> Debug as=> Eclipse application will cause code changes to be swapped into the runtime VM as you make them, assuming Automatic building is enabled, just as it does for any other Java application. However, it will not make changes in your plug-in MANIFEST.MF or plugin.xml take effect--that still requires restarting and clearing the Configuration space.
When building my first Spring Boot app, I discovered that I need to restart my app every time I make a change to a Javascript file in /resources/static/some-file.js
This is very time consuming.
When I move the files to the /webapps/ folder, it works as expected, but the files are not packaged in a JAR. The docs mention this, so I cannot continue this way.
I read all about spring-boot-devtools, and have installed it in my POM, but the hotswapping doesn't seam to be working. I still need to restart the entire app to see a Javascript or CSS file change.
When the app starts, I can see the line LiveReload server is running on port 35729, so spring-boot-devtools must be doing something...
What would be the steps to further investigate what is going wrong?
My guess is that when IntelliJ runs the app, the files are copied, so when I make a change, I'm actually changing the original files and not the ones used by the running app.
PS: I'm using Maven, IntelliJ IDEA 15 and Spring Boot 1.3.3 with the embedded Tomcat server. I'm not sure what command IntelliJ runs to start the app. The IDE is handling this "automatically". Perhaps I need to change my run configuration?
You need to turn on a couple of features in IntelliJ to make this work.
First, there's a project specific setting which you would need to apply on any project you want to use devtools in. Go to Preferences > Compiler and enable "Make project automatically."
The next setting is an IDEA registry setting that applies to all projects.
In macOS (OSX), press Shift+Command+A (Shift+Ctrl+A in Windows)
Type "Registry" in the search box that appears, and select the registry to open it.
Lookup compiler.automake.allow.when.app.running and enable it.
After that, restart your app. You will notice that the project keeps rebuilding with every change you make. When you check out the result in the browser, you will see both static files and code have been updated.
For Windows users the steps are:
1) Go to File->Settings, then to "Build,Execution,Deployment"->Compiler and enable the "Make project automatically" flag.
2) Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears. Enable compiler.automake.allow.when.app.running flag.
3) Start/restart the app and observe static content reloading.
For IntelliJ 2021.2 version or above below are steps that you need to follow
Add spring-boot-devtools dependency if not already added.
Enable Build project automatically as shown below
Enable option in Advanced Settings as shown below
On Linux, press:
Ctrl-Alt-Shift-/
For mac users I had to press Command + Shift + A
And restart INTELLIJ after Step1 and Step2 without which the registry option was not appearing.
You can user like bellow:
First Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically. Image will look like
Second, we change Registry configuration. Press command+shift+A for macOS or if you are using Windows press Ctrl+Shift+A, and search for Registry. enable compiler.automake.allow.when.app.running.Images look like bellow
Registry image look like..
compiler.automake.allow.when.app.running enable image look like
Then Enjoy..
The option is now in Advanced settings:
The Problem/s:
Views are being compiled but hitting refresh in a browser won't show the changes without restarting the server manually.
Changes to controllers compile automatically using ~run but only a manual server restart will update the content on the server.
Changes to routes under conf are only shown after manually restarting the server.
Background:
running on OSX 10.8.3
using Eclipse Juno 4.2.2
Server is launched using play ~run
Only restarting the server will show changes to views, controllers, routes
To be able to make changes without having to restart the server each time I tried (without success):
in the console: clean -> eclipse -> ~run
in the console: clean -> compile -> ~run
shutdown/restart the computer
Tick Refresh using native hooks or polling -> remove classes_managed from Referenced Libraries and add it manually
Questions:
How can the Auto-Reload functionality be restored?
How can this problem be solved on IDEs besides Eclipse?
Further information:
Playframework reload not working Mac OSX
Auto-reloading with Play framework on a network filesystem
Both of them point to JNotify as the cause for auto-reloading not to work. One of the answers (not enough rep to write a comment) mentions how one could "hack Play framework's sbt plugin to make the PlayReloader trait behave as if JNotify wasn't available." How could one achieve this?
The following got Play's auto-reload to working with Eclipse:
In Eclipse Preferences go to General → Workspace. Uncheck Build automatically.
Restart OS X.
For whatever reason, I had to restart OS X to get akim's suggestion to take hold.
I got around this problem by changing the project configuration in Eclipse. I unchecked the "Allow output folders for source folders" option, which means that Eclipse will compile classes to the "bin" folder. This prevents the Eclipse compilation from interfering with the Play compilation. The only downside is that you have to remember to redo it if you ever do play eclipse again.
Following akim's suggestion, disabling Build automatically under General\Workspace in the Eclipse Preferences solves the problem and re-enables Play!'s auto-reload functionality in all of the above problem cases.
I reinstall my Eclipse environment every year when the new version is released. The most recent release - Juno - however, does not work as expected.
Currently, when I try running demos from Oracle, for example, it asks me to select an Ant file to run before compiling. After creating a blank Ant file to bypass the requirement (which I thought was rather dumb, since I don't think TDD is something that should be forced on people), it still refused to run, saying the "Selection could not be launched."
I understand that Juno is an update from the 3.x track to the 4.x track, but this seems a little ridiculous to me. What can or should I do so I can get Eclipse back up and running again?
Just to clarify:
All files in question are on my Eclipse workspace path
I don't do much in the way of Java development, though I know I'll need to do so soon. Hence, my unfamiliarity with the most recent version of Eclipse.
I would like to run my files & projects without Ant files. I know it has something to do with Run configs, but I don't know how to change them.
Here's what I did to run the demo from Eclipse Juno:
Downloaded the project from http://docs.oracle.com/javase/tutorial/uiswing/examples/zipfiles/components-FrameDemoProject.zip (if this is not the correct demo, then please provide the link you're using)
Unzipped it to my projects directory (not my workspace), so that you have:
PROJECTS_DIR/components-FrameDemoProject/src
PROJECTS_DIR/components-FrameDemoProject/nbproject
PROJECTS_DIR/components-FrameDemoProject/build.xml
From Eclipse, File > New > Java Project
List item Uncheck Use default location and navigate to <PROJECTS_DIR>/components-FrameDemoProject
Hit Finish
Drill down to src/components/FrameDemo.java
Right-click on FrameDemo.java and select Run As > Java Application
Let me know if any of these steps give you trouble.
Take a look at you project properties and select the Builders entry. Do you see an Ant Builder entry? Try to select or create a Java Builder entry instead.
I just created a new Java Project in Juno and added the FrameDemo.java source. In my case, the Java Builder was selected as the default for this new project.
What is the purpose of Build Automatically option in Eclipse (Project-->Build Automatically)? Mine will always be checked. But when ever I have some java code changes I still have to do a full build. I was told that it should always be checked. I don't see any benefit in doing so. Please somebody explain.
Eclipse has a good answer on their website:
You have two modes of working: auto-build mode and manual build mode. By default, you are in auto-build mode and Eclipse takes care of compiling source files automatically. Builds occur automatically in the background every time you change files in the workspace (for example saving an editor). Auto-build is convenient because it means problems view, binaries, etc. are are up-to-date at all times. The downside is that in large workspaces auto-builds can be time-consuming if you are changing files in projects with lots of downstream dependent projects.
If auto-build is taking too long and is interfering with ongoing development, it can be turned off. Once in manual build mode, the user is in complete control over when builds occur and what gets built. Project > Build All (Ctrl+B) can be invoked at any time to trigger what auto-build was doing automatically. This allows you to build up a larger set of changes before invoking a build (Eclipse remembers which files have changed so that it does not have to do more work than required when you do ask for a build.
Note that when they say "auto-build mode" they mean if you have checked "Build Automatically", when they say "manual build mode" they mean you do not have "Build Automatically" checked.
Yes, you still have to do a build - but it's done automatically when you save (not an external build like an Ant build, but the "internal" build). If you didn't want to build on save, you'd uncheck the box. Having it build automatically makes some people nervous, I believe.
NOTE
For C/C++ users it's told (from help.eclipse.org):
By default, the Eclipse workbench is configured to build projects automatically. However, for C/C++ development you should disable this option, otherwise your entire project will be rebuilt whenever, for example, you save a change to your makefile or source files. Click Project > Build Automatically and ensure there is no checkmark beside the Build Automatically menu item.
Project - Disable Autobuild option does not always mean autobuild is off. For example "Makegood" test automation plugin will trigger autobuild when Preferences - Run/Debug - launching - (General opt) Build before launch is ON. So turn it off if manual build needed.
One thing that people didn't mention here (and it took a while for me to figure this out too) is that eclipse build (either automatic or manual) would basically follow what you have outlined in the project's "Java Build Path" source tab. So when a file is covered in that build source tab, when you change the file, it gets copied/compiled to the output folder that was specified for that directory/file.
One more difference is:
Most of the time while working on JSPs it helps me when checking "Build Automatically". It automatically picks up the changes in JSPs.
But if you make changes in your java classes/XMLs you need a manual build.
Since I'm using resin server which is run outside eclipse via command prompt, i prefer checking the option.
When i have my server setup in eclipse, i turn it off and use Publish on server.
This is the way i use and the answer is based on my experience.
If Build Automatically is checked, the IDE will automatically compile your Java code whenever you modify and save a file. This does not mean it will completely build and package your entire solution as if you were going to deploy it such as if you are working in a Web project on a WAR module. It basically really just compiles your code.