eclipse configuration files - link a source directory using variable - eclipse

When you add a folder in eclipse using link a source directory we can use variables. I need to know where these variables and their values are stored. Is it in a configuration file?
I followed the below , Went to eclipse, (java) project properties, and then java build path.
Now I clicked on link source and added a variable - say top_root and pointed to a location say - c:\temp
I used the same to link a source directory. This information is available in .project file.
I need to know, in which file test=c:\temp will be configured / available.
<link>
<name>java</name>
<type>2</type>
<locationURI>top_root/src/java</locationURI>
</link>

eclipse-3.5.2\workspace\\.metadata\\.plugins\org.eclipse.core.runtime\\.settings\org.eclipse.core.resources.prefs
The configuration was available, Inside the above folder, this file org.eclipse.core.resources.prefs
pathvariable.top_root=C\:/temp
search for all prefs files

Related

Property file not available in bin folder while building in Eclipse

I have a Project that I have built on Eclipse. I have a property file added in the src directory. The java class file is available in bin, but the property file is not available. Where am I going wrong?
Assuming the type of project is Java Project
Right click on the project and select properties option. Check in the Java build path all files under source folder are included or not and also check if some files are excluded.
In my case property file is being copied to bin folder. See the picture below.
Hierarchy of source folder and bin folder are same in my case.
If project is of type plugin project
Open the Manifest.mf file in Plugin Manifest editor and go to Build tab. Check the property file is selected here if NOT then select the file and check.
Edit:
Troubleshooting steps:
Simply Restart eclipse and completely clean and build the workspace and check.

How to place a file on classpath in Eclipse?

As this documentation says, "For example if you place this jndi.properties file on your classpath", but how can I place the .properties file on my classpath if I am using Eclipse?
Just to add. If you right-click on an eclipse project and select Properties, select the Java Build Path link on the left. Then select the Source Tab. You'll see a list of all the java source folders. You can even add your own. By default the {project}/src folder is the classpath folder.
One option is to place your properties file in the src/ directory of your project. This will copy it to the "classes" (along with your .class files) at build time. I often do this for web projects.
This might not be the most useful answer, more of an addendum, but the above answer (from greenkode) confused me for all of 10 seconds.
"Add Folder" only lets you see folders that are the sub-folders of the project whose build path you are looking at.
The "Link Source" button in the above image would be called "Add External Folder" in an ideal world.
I had to make a properties file that is to be shared between multiple projects, and by keeping the properties file in an external folder, I am able to have only one, instead of having a copy in each project.
Well one of the option is to goto your workspace, your project folder, then bin copy and paste the log4j properites file.
it would be better to paste the file also in source folder.
Now you may want to know from where to get this file, download smslib, then extract it, then smslib->misc->log4j sample configuration -> log4j here you go.
This what helped,me so just wanted to know.
Copy the file into your src folder. Go to the Project Explorer in Eclipse, Right-click on your project, and click on "Refresh". The file should appear on the Project Explorer pane as well.

Linked resources in Eclipse in multiple workspaces and OSs

I have some Eclipse projects that need to run on multiple machines and OSs.
All the projects share a data folder, so the most logical thing to do is a workspace linked resource pointing to that folder. So I set a DATA_DIR linked resource on every workspace, e.g. c:\data on Windows, /home/mulone/data on Unix/Mac, etc.
Then in the .project file of each project I manually added the following:
<linkedResources>
<link>
<name>data.txt</name>
<type>1</type>
<location>${DATA_DIR}/data.txt</location>
</link>
</linkedResources>
The strange thing is that works perfectly on Mac/Linux, but on Windows7 I get the following error: Could not open the editor: Must specify a URI scheme:$%7BDATA_DIR%7D/data.txt
I'm using Eclipse 3.6.
Mulone
You can modify the .project file programmatically using: org.eclipse.core.internal.resources.Project.setDescription(..) - basically setting the IProjectDescription which is the exact mapping of the .project file.

Eclipse: How to add an existing source folder?

I have a directory called c:\RemoteSrc . Under this there are 3 directories which are currently source folders (I think? the icon is an open folder with a little orange grid in it) in my Eclipse project. I have dropped a new directory under c:\RemoteSrc which I also want to add to my project.
BUT
If I right click on my project and go "Build Path..." -> "Link Source" and try to add it it tells me "Folder already exists with a different case". Yes i KNOW that the folder already exists THATS WHY IM TRYING TO ADD IT.
I think all you need to do is refresh the project. Eclipse does not automatically pick up folders (or files) dropped into it's project directory.
A screen capture might help, but if the GUI is un-cooperative, you can:
close Eclipse
open the .classpath file which defines your project (it may be located in your workspace)
see if you can define a new classpathentry of kind "src": this is not the easy method, but that may give you an idea why the GUI refuses to define the same entry.
For Linked Sources, you should have something like the following in your .classpath
<classpathentry kind="src" path="module_name"/>
With a corresponding matching entry (within <linkedResources>)in your .project
<link>
<name>module_name</name>
<type>2</type>
<location>path/to/your/module</location>
</link>
NOTE: Removing a linked project doesn't necessarily remove it from the project.
No need to close Eclipse.
Open .project file using Notepad++, find link to the existing source/folder and delete it. Save the file.
Refresh the project in Eclipse.
Now you should be able to link it again.
I had a problem where I had created a /src directory in my working directory and then wanted to link another directory with additional files to import. The "existing directory" turned out to be because the directory I was trying to link was also called "/src", even though the path was different. I guess Eclipse can't have two /src directories in the same project, similar to trying to mount two file systems at the same node. I rearranged the directories so there was only one /src, and all was well.
There were conflicts when I tried to update my project which resulted in creation of multiple .classpath files.. SO removing the copies and reverting the latest .classpath file and then refreshing/rebuilding project ,solved the issue for me.
Hope it helps!
Sometimes the simple refresh (Greg Adamski's answer) does not work, e.g. because the source folder is not in the src-directory (in my case, I had to reference Swagger auto-generated code which was located deep in the target/.... directory after a Maven Build).
In this case, right click the project, open the 'Build Path' -->'Configure Build Path' dialogue, select the 'Source' tab and select your additional source folder via the 'Add Folder' button.

FDT / Eclipse : path variable

I am trying to create a script that would list all the linked libraries in an FDT project and their corresponding svn repositories.
My problem : I was not able to find the file on my system where Eclipse (or FDT, I'm not even sure) writes all of the path variables.
I have tried capturing changes on my system and have had no luck.
If anyone knows where to find this file (Mac OS X) or knows a technique I could use to find it, it would be very appreciated.
Thanks.
In FDT, you can find the list linked libraries in the .as3_classpath file if those libraries are in your project folder (or below). They reflect the content you add in the 'Library' tab of 'FDT Build Path' in your project's properties. There's also an entry in the .project file that reflect the linked libraries you add with the 'Source' tab. Those libraries can be located anywhere on your hard drive, and that's why you define 'path variables' for them.
Personally, I create a 'lib' folder in my project where I copy the libraries I need and add them with the 'Library' tab. I find it much easier to share the project (since everything is relative to the project) and you don't need to worry about having two projects modifying the same library file.
For the location of those 'Path' variables, as far as I know, could only be located in your eclipse installation folder or in your eclipse 'settings' folder, usually in your 'user' directory.