How do I make Eclipse move this project? Error: another process has locked .metadata/.lock - eclipse

In Eclipse, if you want to reorganize your filesystem, you cannot just move your Eclipse project's files on the filesystem. Instead you right-click your project in Package Explorer -> Refactor -> Move, and select the new path (which I learned from this answer).
However upon attempting this move with the Minecraft Forge Eclipse workspace project, I get a "Move Problems" error dialogue with the error message
Could not move /MDKExample
Could not move C:\Users\user\forge-1.8.11.14-mdk
Could not read from source when writing file C:\Users\user\forge-1.8.11.14-mdk\eclipse\.metadata\.lock
The process cannot access the file because another process has locked a portion of the file
After clicking through the dialogue, the source and destination of the moves are both left in an unusable state due to the half-completed move of files. Downloading fresh copy and rebuilding the Eclipse workspace with gradlew setupDecompWorkspace && gradlew eclipse (instructions), the move fails every time. What is the secret to moving a project in Eclipse?
It's a Java project, and I'm using Eclipse Mars.1 (4.5.1) on Windows 10 with Java 8. Creating a blank Java project and adding a few files, Refactor -> Move works fine, so is this problem something particular to this Eclipse Java project?

Related

What exactly is a "corrupted workspace"?

I've been working on an Android project in Eclipse Indigo for a year on a PC that has updates turned off and no new software installed (deliberately to avoid any instability in the java runtime or other installed software).
This morning Eclipse froze and when I killed it in Task Manage, rebooted the PC and restarted Eclipse it failed to launch, saying
"Eclipse failed, Java was started but returned exit code=-805306369”
Googling this I discovered here . . .
http://spacetech.dk/eclipse-failed-java-was-started-but-returned-exit-code-805306369.html
. . . that this is due to a "corrupted workspace". And that I should rename the workspace, create a new empty one, and import the old project into it.
1. What exactly is a "corrupted workspace"? Is there a particular file that's missing or damaged or locked? Can the "corruption" be debugged? A chkdsk didn't show any problems with the disk. I've never had this happen in Visual Studio with C# projects and I do more Windows development than Android.
2. What's the process for importing the old project into the new workspace, and how do I do it without importing the corruption? It's a big project with hundreds of files so I don't want to try to recreate it by hand.
The workspace is a set of configuration files and your projects, though projects can also exist outside of the workspace. The are configuration files for most of the eclipse plugins you have installed, I suspect one of these is causing the problem.
The configuration is stored in a hidden folder in the workspace called .metadata, their is also a log file in this folder called .log. This log file might give you more of a clue as to what has broken.
You can delete (or move it somewhere else) the .metadata folder and eclipse will recreate it next time it's launched. You will then need to reimport your projects and configure eclipse again.
To reimport your projects, use the import wizard from the "File -> Import" menu item. Select the "General -> Existing projects into workspace" wizard. Now click the "Browse" button and find your projects. Select the projects you want to import and click "Finish". Your workspace should now contain your projects again.

Disable automatic "Updating projects..." action in Eclipse CDT

I am using a quite large project in Eclipse, composed by different libraries which can be build independently thanks to dedicated "Make Target" elements.
When compiling one of this libraries, the compilation works fine, but afterwards, Eclipse keeps busy by doing "Building Targets. Updating projects..." (as named in the Progress View). As my project is rather large, this action takes several minutes, preventing me to start new compilations or change Eclipse settings.
Is there any way to disable this automatic update in Eclipse?
I have observed this behaviour in Eclipse Helios and Eclipse Juno.
I have tried to remove my "Make target" objects, and give an invalid C/C++ Build configuration (e.g., provide an invalid make command).
As expected, when building the project, Eclipse tries to execute the invalid make command (which fails), but then keeps doing this "Updating projects..." anyway...
After build Eclipse is looking for newly created executables. If your project is Makefile-based Eclipse cannot be sure where to search and browses the whole source tree.
Assuming your executable are all go into a folder bin-XXX, you can reduce these searches as following:
Select the top project (say "src") and go to the right-menu dialog “Properties” (alternatively: top menu Project-Properties). Then go to “C++ build”-“Refresh policy”. Here select the folder “src” and press “Add Exception”. Then add all folders except “bin-XXX” as an exception.
Select the top project “src” and go to the right-menu dialog “Properties” (alternatively: top menu Project-Properties). Then go to “C++ General – Paths and Symbols – Output Location”. Add folder “bin-XXX” and remove the folder “src”

No HTTP Preview server for Eclipse Juno in Ubuntu 12.04

I just installed Eclipse Juno on Ubuntu 12.04 (32-bit) and downloaded the Eclipse Web Developer Tools. I created a new Static Web Project but cannot create/use HTTP Preview for the Target runtime to test/run my project. Does anybody know whether this is possible? If so, how would I do this?
You can create the patch and make it work for the Eclipse Juno version you have in the following four phases. Its a bit lengthy but it works
Phase 1: Create a plug-in project for the plug-in you need to patch.
Create a new workspace (recommended) or open an existing one.
Select File -> Import
Expand Plug-in Development, select Plug-ins and Fragments, then click Next
In the Import As section, select Projects with source folders
and then click Next.
Enter (or copy & paste, no quotes)
org.eclipse.wst.server.preview.adapter into ID field at the top and
click Add All. This should move this one plug-in to the right pane.
Click Finish to import the "org.eclipse.wst.server.preview.adapter"
plug-in source into a project.
Expand the root of the project and ensure it contains a folder named
"src". You will only get the "src" folder if you have the "WST Server
Adapter Plug-in Developer Resources" installed.
Phase 2: Apply the changes needed to update the plug-in. Since there is a bug with a patch attached that can be used to apply the changes, the following steps will take advantage of that.
Open Bug 402848 in a browser.
Click on the Patch v1.0 for 3.4.2p attachment link to open the patch.
Starting with the second occurrence of a line starting with ---,
select this line through the end of the text and copy it to the clipboard. This contains the changes to the PreviewLaunchConfigurationDelegate.java file which is where the fix is
needed. You don't want the upper portion of the patch as that would change the version of the plug-in, and that would complicate things.
Back in Eclipse, right-click on the "org.eclipse.wst.server.preview.adapter" project. Select Team and click on Apply Patch.
Leave Clipboard selected and click Next.
Ensure the "org.eclipse.wst.server.preview.adapter" project is
selected, and click Next.
Set the Ignore leading path name segments to 3. The "Patch
Contents" window should change to have a blue left pointing arrow
instead of red x indicators.
Click Finish to apply the changes.
Phase 3: Create the replacement jar. Due to the approach in Phase 1, the name of this jar will be identical to your current jar, which simplifies updating the Eclipse installation.
Right-click on the org.eclipse.wst.server.preview.adapter project in the Project Explorer or other navigator view and select Export
Expand Plug-in Development, select Deployable plug-ins and
fragments, then click Next
Click the Browse button next to the Directory selection in the Destination tab followed by OK. This will set the output directory to be the same as your workspace.
Click Finish to build the replacement plug-in jar. It will appear in
a "plugins" folder under the root of your workspace.
Phase 4: Replace the installed plug-in jar with the fixed version.
Exit Eclipse if it is running.
Under the "plugins" folder of your Eclipse installation, move or
rename the org.eclipse.wst.server.preview.adapter_1.1.101.v20121107_1651.jar if you
don't want to overwrite it with the patched version (mentioned in step 3 below). If you have a different version, it means you aren't using Juno SR2 and hopefully you installed the "WST Server Adapter Plug-in Developer Resources" that matched your version.
Copy the org.eclipse.wst.server.preview.adapter_1.1.101.v20121107_1651.jar from
the "plugins" folder under your workspace and paste it to the "plugins" folder of your Eclipse installation.
You should be able to run Eclipse now with the fixed plug-in. Because the patched jar had the same version number, no additional changes are needed.
I'm not familiar with the tooling you're using, but I had big problems with eclipse's internal browser on 12.04 as it was trying to use mozilla's XULRunner. The packaging of XULRunner has changed in 12.04 due to mozilla's release cycle, and isn't included in the repo independently. I forced my eclipse to use WebKit, by setting the following property in the vmargs section of my config.ini
-Dorg.eclipse.swt.browser.DefaultType=webkit
This sorted my issues out - hope this helps with yours.

How do I open the GWT samples in eclipse Helios and GWT 2.1.1?

What is the straight-forward way of importing one of the GWT samples in eclipse Helios + GWT 2.1.1. It seems like the content of the zip file doesn't contain any project files for eclipse.
I tried the following:
create a GWT project 'bla'
Delete the src ad war folder and
replace it with the src and war
folder from the sample
refresh the project in eclipse
hit 'run'
[ERROR] Unable to find
'bla/bla.gwt.xml' on
your classpath; could be a typo, or
maybe you forgot to include a
classpath entry for source?
So I go to the run configuration and remove the path for the example projects from the arguments list. I also changed the name of hosted html page to the one in the sample. Hit 'run' and:
[ERROR] Invalid version number "2.0"
passed to external.gwtOnLoad(),
expected "2.1"; your hosted mode
bootstrap file may be out of date;
Now I need an out of date version of GWT to run these samples? What is going on, I just want to look at a sample to learn a new concept.
Reading the readme.txt in the GWT samples directory I came across a solution that works on Eclipse 3.7. Assuming you have ant installed on your machine, execute the following from the sample's directory:
ant eclipse.generate
This will generate both the .classpath and .project files needed to import the sample into Eclipse and run it.
Here the relevant excerpt from README.txt:
-- Option A: Import your project into Eclipse (recommended) --
If you use Eclipse, you can simply import the generated project into
Eclipse. We've tested against Eclipse 3.4 and 3.5. Later versions
will likely also work, earlier versions may not.
If the directory containing this file does not have a .classpath or
.project file, generate them by running 'ant eclipse.generate'
In Eclipse, go to the File menu and choose:
File -> Import... -> Existing Projects into Workspace
Browse to the directory containing this file, select "Mail".
Be sure to uncheck "Copy projects into workspace" if it is checked.
Click Finish. You can now browse the project in Eclipse.
To launch your web app in GWT development mode, go to the Run menu and
choose:
Run -> Open Debug Dialog...
Under Java Application, you should find a launch configuration
named "Mail". Select and click "Debug".
You can now use the built-in debugger to debug your web app in
development mode.
In eclipse 3.7, instead of Run -> Open Debug Dialog..., its Run -> Debug Configurations. I got both the showcase and mail samples running following those commands. Should work for all of the other samples as well.
The examples that come with GWT SDK were built in different ways. Some are Maven builds, others use Ant. Eclipse can handle these common builds directly, but you have to choose the right option.
So, if you want to open the Expenses project in eclipse, you would look in the projects root directory (i.e. ../gwt2.4/samples/Expenses) where you'll find a file called pom.xml. That is a Maven build file. To import it into your Work space select:
File->Import...
Open Maven->Existing Maven Projects, and click on Next > button
Browse your file system til you reach the Expenses folder. Click on it and Select OK.
At this point it will show you the Projects in that directory in the Projects: area of the window...only one in this case: /pom.xml com.google.gwt.sample.expenses:...etc.
click on the checkbox for that project, Next>
Finally, it ask you to map plugins. You'll need to select in the drop down menu under Actions the required plugins (such as m2e).
In other project folders you may find a build.xml file instead. That's an Ant build file. To import that you do something similar, but different (of course!):
File->New->Project...
Open the Java folder and select "Java Project from Existing Ant Buildfile", Next >
Click the Browse button, dig through your directory to the project folder and select the build.xml file, and Open it.
Project name should fill in automatically, just select the declaration to use in the middle window and click Finish.
Since those tutorial only include the src and war directory, the idea remains to:
create a new project following this tutorial
remove any created class part of the example files which are automatically added (see Issue 1547)
Unfortunately the Google Plugin does not allow to created a new Web Application Project without creating template files. The template files are nice for the first try but annoying if you want to start from scratch with a new GWT application.
copy the src and war directory in place within the now empty project
Following your ticket 5847 (No easy and straight-forward way to make examples work in eclipse),
as xo4yhamope comments, you need the right GWT option.
and did you consider the Issue 5038 about the error message:
Unable to find 'xxxx.gwt.xml' on your classpath;
could be a typo, or maybe you forgot to include a classpath entry for source?
This message usually means you attempted to refresh the browser before dev mode has had a chance to finish loading the module.
The uppercase/lowercase confusion happens because the module has been renamed to 'stockwatcher', but dev mode cannot map 'stockwatcher' to "StockWatcher' until it has finished loading the entire module.
So, it's just a matter of waiting a few seconds longer after the Development Mode pane says I should go to http://127.0.0.1:8888/StockWatcher.html?gwt.codesvr=127.0.0.1:9997 ?
That seems a little messed up. It should wait until it's actually ready before telling me it's ok, because users (like me) are going to go there as soon as the UI says it's ready.
The other confusing part is that the server begins serving the host page as soon as that message in the UI comes up. Because this was happening, I assumed that the server was completely up, even though (as it turns out) it wasn't.
Anyway, waiting a few more seconds seems to resolve the "Unable to find 'stockwatcher.gwt.xml' on your classpath" problem. Thanks!
I'm beginning to suspect this is a bug in the samples. I am adding this answer so it can be marked as an answer when I get confirmation about that.
I was trying out some other samples and came across this page. At the top is a little explanation for how to download and import the sample.
Before you begin
The StockWatcher project
This tutorial builds on the GWT
concepts and the StockWatcher
application created in the Build a
Sample GWT Application tutorial.
If you have not completed the Build a
Sample GWT Application tutorial and
are familiar with basic GWT concepts,
you can import the StockWatcher
project as coded to this point.
Download the StockWatcher project.
Unzip the file.
Import the project into Eclipse
From the File menu, select the Import... menu option.
Select the import source General > Existing Projects into
Workspace. Click the Next button.
For the root directory, browse to and select the StockWatcher
directory (from the unzipped file).
Click the Finish button.
If you are using ant, edit the
gwt.sdk property in
StockWatcher/build.xml to point to
where you unzipped GWT.
Now this is what I call straight-forward and easy.
At that point I had already built the StockWatcher in a previous tutorial but I got intrigued by the fact that it was explained exactly as I tried it the first time. So I downloaded the project and it had the correct eclipse project structure. I tried to import it 'et voila' I have the project in eclipse. I runs out of the box (with warnings). That is how expected the samples to be.
This experience leads me into thinking that the sample projects are malformed (as eclipse projects) and need to be updated. Let's hope my issue report leads to results.
-- Option A: Import your project into Eclipse (recommended) --
If you use Eclipse, you can simply import the generated project into Eclipse.
We've tested against Eclipse 3.4 and 3.5. Later versions will likely also
work, earlier versions may not.
If the directory containing this file does not have a .classpath or .project
file, generate them by running 'ant eclipse.generate'
In Eclipse, go to the File menu and choose:
File -> Import... -> Existing Projects into Workspace
Browse to the directory containing this file,
select "Mail".
Be sure to uncheck "Copy projects into workspace" if it is checked.
Click Finish.
You can now browse the project in Eclipse.
Copy from readme.txt supplied by samples. I tried this method, it's OK.
To import GWT showcase(2.5.1) I did following steps:
Create a new Google Web Application Project
New –> Other –> Google –> Web Application Project
Provide the project name “Showcase” and the Package name is com.google.gwt.sample.showcase
Click Finish
Go to eclipse plugin folder and traverse to the gwt
Under that folder go to gwt-2.3.\samples\Showcase
Copy (Ctrl C) all the contents. The contents are
a. src
b. test
c. war
d. build.xml
e. README.txt
In the eclipse, right click on the Showcase project and paste. Overwrite all the files
The files should start copying without any problem
Right click on the Showcase and Run As “Web Application”
You should have your Showcase working like Gem!
For me it worked like a charm ;)
Ref : http://simplestepswebdev.wordpress.com/2011/05/16/import-gwt-samples-into-eclipse/

Moving project to another folder in Eclipse

I generally have my working projects sitting on folders on my Desktop. When they are completed I just move them to a c:\dev\. The thing is I'm doing it in a rather archaic way.
1. move project files
2. delete project on Eclipse
3. create new project on Eclipse on the new location
How to you guys move projects around?
If I could alter the: File -> Properties -> Resource -> Location path it would be dead simple!
Example move:
c:\user\desktop\project_123
c:\dev\project_123
Right click on the Eclipse project in the Package Explorer, select Refactor, then select Move... In the dialog that comes up, enter or navigate to the new location and click OK. This will also preserve your CVS or other SCM metadata, but will also bring all your modifications as well, and you won't lose any memberships in Working Sets, launch configurations, or other things that Eclipse associates with your project.
Use Eclipse's Move menu item
Open Navigator view, right click on your project and click Move. Then select the destination directory.
Navigator View > Right Click > Move
Note it doesn't seem to work in Package Explorer (at least not in Neon). The move dialog from Package Explorer is different, so use the Navigator window.
I don't know whether eclipse has made modifs since the date of this post...
In my case I had moved a project folder manually and I wanted Eclipse to open the project on this new location. This is what I did (and it seems to work).
(I'm using eclipse "helios" v 3.6.2)
File menu | Import ...
General | Existing projects into Workspace
Select root directory = top directory of your project on the new location
Finish
I rarely have any projects in Eclipse that aren't under source control, so all I would need to do is check the project out in the new location.
If you don't have source control, Eclipse works with CVS rather well out of the box, and it's pretty simple to setup CVS to run locally without a server: http://www.tortoisecvs.org/faq.html#cvsinit
WHEN EVERYTHING ELSE FAILS:
Copying an Eclipse project from one directory (let's call it old_dir) to another directory (let's call it new_dir):
Open Eclipse and specify the copied working directory in your new_dir.
Once it opens the project in the this new_dir, the projects listed under Project Explorer Tab might still be the ones contained in the old_dir (you can check it by right clicking each and following through: "Resource -> Linked Resource" to see the Path Variables values). Thus, they have to be removed from this work space. Delete the Nios 2 Application Project and the BSP Project from the Project Explorer Tab by right clicking on it and selecting Delete option which will pop a new window. In the pop-up window, make sure that the Delete project contents on disk check box is UNCHECKED before clicking OK to delete the Projects. Otherwise, it will delete it from the old_dir where you copied the project from.
Right click in the Project Explorer Tab Area → Import → General → Existing Projects into Workspace and add the copied Nios2 Application Project and the BSP Project from the new_dir.
Right click in the Project Explorer Tab Area → Index → Rebuild, otherwise the Nios2 Application Project will not be able to use the includes provided by the BSP Project.
Click on Project → Clean → OK to clean and rebuild the whole project.
When using console to talk to the NIOS, make sure elf's path is updated to the new project directory as well!
Right click on your project->copy.
right click in project explorer free space and right click->pase.
chose new folder and project name.
I copied the whole project to a new directory. After setting Eclipse to the new workspace it recognises the project instantly. Thus it was nothing further to do. I use Eclipse IDE for C/C++ Developers, Version Luna Service Release 2 (4.4.2).
For Eclipse Oxygen, to move a Java project, djb's accepted answer works well (in my experience just now), except having read comment by Basic May 14 '12 at 9:27, I tried to add my project XMLDiff to C:...\SVN\trunk\Internal Projects, and I got a failure with the rather cryptic message:
Problems encountered while moving resources.
Resource already exists on disk.
I had to move the project to C:...\SVN\trunk\Internal Projects\XMLDiff by creating a new folder, XMLDiff, in the browse dialog, and the result was C:...\SVN\trunk\Internal Projects\XMLDiff, not C:...\SVN\trunk\Internal Projects\XMLDiff\XMLDiff.
So this must have changed between Basic's experience in 2012 and Eclipse.3.
For Eclipse Oxygen
Project Properties -> Resource -> Linked Resources -> Linked Resources (Tab)