eclipse, refresh files edited by external editor - eclipse

I currently use emacs to edit .java files and run eclipse.
Eclipse doesn't automatically recognize modified files, so I often end up running unmodified application.
I wonder if there exists a shortcut to refresh all the modified files in eclipse.

Perhaps you want to check Preferences > General > Workspaces > Refresh using native hooks or polling. You can see that the eclipse refreshes the file you edit with external editor (like vi, emacs, etc) when you check the option.

On the project explorer you need to select the project(s) that you want to refresh and then click on File->Refresh or hit F5.

Related

Eclipse not automatically refreshing resources in src/main/resources

In my Eclipse preferences, I have "Refresh using native hooks or polling" selected.
If I make a change to a Java file outside of Eclipse, the project that contains that Java file automatically refreshes and rebuilds that file as it should. However, if I make a change to a file under src/main/resources/... from an external editor, it is not automatically refreshed. I have to select the project and press F5 to get it to refresh.
Is there a way to configure Eclipse to automatically refresh any resources under src/main/resources?
In Eclipse
Run > External Tools > External Tools Configuration
Create a new Program configuration Point the location to an exe that is very fast
On the Refresh tab, choose Refresh Resources upon completion, The Entire Workspace
On the Build tab, deselect Build before launch

image won't show in Eclipse dynamic web project

I have a folder containing images under WebContent. If I copy file 1.jpg to images using Windows Explorer, it won't show on my webpage:
document.getelementById("image1").src = "./images/1.jpg"
However, if I right click the project in Eclipse, refresh, then everything works.
How do I remove the need to refresh the project? The images are supposed to be generated by another program dynamically
If something outside of Eclipse modifies the workspace it is always necessary to do a refresh.
However you can configure Eclipse to do this automatically in Preferences > General > Workspace. Check the 'Refresh using native hooks or polling' option.
If the program generating the images is an Eclipse plugin it can use Eclipse APIs to create the files or do the refresh (a normal program cannot do this).
If you run the program using Eclipse Run External Tool configuration there is a Refresh tab that will let you set up the refresh to do when the program terminates.

How can I refresh the eclipse folder with another tool?

I create a web based project with eclipse and the application server is Tomcat and everything is OK, but I have a few files in specific folder that I should change the content of these files with another development environment that it's created by myself, after I change the file's the eclipse doesn't refresh the file and therefore I must go to eclipse, select the folder, press f5 to refresh it.
My Question is that, How can I refresh that specific folder without doing these steps, for example does eclipse have specific API for refresh the folder?
You can use IResource.refreshLocal to refresh a folder (or file).
One way to use this:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IContainer folder = root.getgetContainerForLocation(new Path("folder path"));
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
This must be run in an Eclipse plugin.
Update:
You can tell Eclipse to refresh automatically in Preferences > General > Workspace by checking the 'Refresh using native hooks or polling' option.
There is no way to force a refresh from a program external to Eclipse.

Sublime Text 2 edited file-changes does not show when refreshing browser in Maven project

I am having problems when editing template-files(HTML-files) in my Maven-project. I have made the Maven-project an Eclipse-project with the command "mvn eclipse:eclipse" (if it matters). I am using the Apache Velocity Engine as template engine for this project.
The problem arises when I'm editing the files in Sublime, and then save the file and refresh the browser. The changes does not show! If I however open the template file in Eclipse, just open it, I can even just open and close it right away, and THEN refresh the browser, the changes will show.
I have done a test to see if this problem occurs on other simple projects as well, and with a single HTML-file and a simple http-server, the work I save in Sublime shows as normal.
Does anybody know what is happening here? Am I bound to keep on using Eclipse as a HTML-editor? :( Does the Eclipse project files prevent me from using other editors? Why are the changes only showing when I open the files in Eclipse?
Any help is greatly appreciated!
In order for the changes to take place you have to right-click the file in Eclipse explorer tab and choose "refresh" in order for the (static) changes to be reloaded to Apache. For dynamic changes you'll need to restart apache or use a plugin such as JRebel.
Eclipse copies the files to the "target"-folder in the webapp. Sublime(and others) does not do this automatically, so you need to do this manually, or by a plug-in that will copy the files on save.

Can Eclipse refresh resources automatically?

Eclipse (3.4.2 with PyDev) deals with out-of-sync resources (files that have been edited outside of the IDE) differently from other IDEs that I've used, where only resources with editors open are considered out-of-sync. In Eclipse, any resource can go out of sync.
This means that when I perform a search after any file has changed outside of Eclipse, I get an error dialog telling me that files are out of sync, even if they have no open editors. As far as I can tell, there is no global refresh command, so I'm forced to read the project names (I have several projects) in the error dialog, and do a right-click + refresh for each of them.
I've checked the Refresh Automatically setting in Settings > General > Workspace, but this has no effect. Is there any way to get Eclipse to always just load non-active resources from disk?
This issue will be fixed in Eclipse 3.7 (Indigo). While "Refresh Automatically" does eventually bring resources back into sync, the refresh hook only exists for Windows, so on Linux and Mac OS it has to poll the filesystem periodically.
From 3.7 there's a new preference Settings > General > Workspace > Refresh On Access (aka Lightweight Refresh). This preference causes Eclipse to automatically refresh resources when it discovers that they're 'out-of-sync'. When opening, reading or searching files, it'll prevent out-of-sync errors from occurring.
See also: https://bugs.eclipse.org/303517
I think if you click on the project node in the Project Explorer and press F5 or right click and select Refresh, all resources for that project will be refreshed. Also, if you CTRL+click on multiple projects, you should be able to refresh multiple projects at the same time.
A single click on a project, a CTRL+A to select everything, and an F5 should do exactly what you need - refresh everything.
I'll have to test this when I get the chance, but I believe this is how I overcame similar problems in the past.
I've noticed that this answer routinely is getting down voted. I'd like to point out that the question refers to a specific version of Eclipse: 3.4.2. There was actually no automatic method to refresh out-of-sync resources until version 3.7 Indigo of Eclipse, as mentioned in James Blackburn's answer. The method described in this answer is the only method to achieve this in version 3.4.2 (and any other version before 3.7 Indigo).
Out of synchronization problem is common in eclipse IDE so you have to check this option windows -> preference -> Workspace -> refresh using native hooks or polling.
Eclipse Helios possesses a built in refresh feature at Preferences > General > Workspace. It's in the same spot where you disable automatic builds. Select refresh automatically. A plugin with the same functionality is Andrei Loskutov's Filesync Plugin. The update site address is: http://andrei.gmxhome.de/eclipse/. During installation, select Eclipse 3.5-3.7 plugins > FileSync.
Given that Java 7 has an api for filesystem hooks, one would think that refresh could be handled better in Eclipse.
Edit: Actually, there is a plugin that uses this mechanism: https://github.com/psxpaul/EclipseJava7Refresher
There is a global refresh - have nothing (or everything) selected in the package explorer and press F5 (or right-click on empty space and select Refresh). Of course, this could take rather long if you have large projects.
The global refresh actually exists in plain Eclipse without any plugins and without selecting every project in your workspace.
Basically you need to deselect everything in your project explorer and hit F5. To do that Ctrl+click the selected resource in the project explorer and hit F5.
A global refresh is really missing in Eclipse. The above procedure with selecting all projects and then running refresh (e.g. F5) does not work if you have closed projects included in your selection. This means, if you have 1/2 of your many projects closed as I do, you find yourself manually Ctrl-clicking through your dozens of projects. This is quite painful. I wish Eclipse would simply ignore closed projects.
Perhaps you should add a feature request on the eclipse site:
https://bugs.eclipse.org/bugs/
I think it would be a great idea to add a preference for automatically refreshing out of date resources.
Yes, Refresh on Access is long overdue ... those answers to this and similar enquires usually suggested enabling the global auto-refresh, which could take an age for large remote projects.
In fact there are those who would say that Refresh on Access should have been the original (< 3.x) default behaviour ...
I managed to solve this by creating a new "external tool" run config that executes a blank batch file. In the run config, you can have it refresh the workspace when complete. Then I created a macro using Practically Macro that 1) executes the last external tool run config (refreshing the workspace), then 2) executes the last debug run config (running my app). If you uncheck "Allocate console" then the completed external tool entry won't show up in the debug window.
Even if the solutions proposed by others perso are indeed correct, you have a "Refresh All" plugin for Eclipse. Simply add the Update page to your Eclipse list of update sites to install it in your IDE.
For Starting up there is an option to automatically refresh files in
Window -> Preferences -> General -> Startup and Shutdown -> Refresh workspace on startup
Click it in order to have a "fresh" start in eclipse. :)
Version: Eclipse 4.12