.classpath contents update in eclipse - java

I downloaded an eclipse project that has a .classpath which has class entries that need to be updated.
What does this do exactly?
Can I change the content of the .classpath in eclipse?
I opened User Libraries in eclipse expecting it to have the same content as .classpath, but there is nothing in it.

The contents of the .classpath file can be changed by modifying the project Java Build Path parameters.
For instance, in Package Explorer, right-click on the project and select Properties... In the Properties dialog, navigate to Java Build Path in the tree. Usually the Source and Libraries tab panels provide most of the information in the .classpath file.

.classpath file stores the classpath metadata info about the project.
There are two ways to edit it:
1. Through UI : right click project -> build path , modify here and you will see changes in .classpath
2.(not advisable) : edit .classpath file, be careful as a small error cud corrupt project.
Edit, save then build/refresh . You should see it updated in buildpath ui. If not, restart eclipse it will pick new .classpath .

Related

Creating a source package folder in a CounterClockWise project programmatically

I have an existing java project and in that project there is a procedure that should programmatically create packages with source files inside them. It uses the standard File.mkdir() method to create all the unexisting directories for the package and then creates and writes the source files in there.
All works fine except that only the top folder created for a package path is marked by Eclipse as a package. The lower level folders remain just folders. For example, if I create a directory structure for package "org.prj.hey.this.is.cool", where "org.prj" is the existing path for my main project package, it then creates the rest of the path "/hey/this/is/cool" and only "hey" becomes an Eclipse package. I have found no way to make Eclipse recognize the "this", "is" and "cool" folders as packages. I haven't found any clues on this in the .project and .classpath files either..
So how do I make the whole branch of created folders be recognized by Eclipse as packages?
UPDATE:
(screenshot)
Found out that the issue is due to the file extension (see the picture). Is there any way to make Eclipse recognize .clj files as source files?
Problem exists in your current eclipse workspace buildpath configuration. Perform rightclick on your project name, then "Build path->configure build path..." and add newly created dirs to your current build path in SOURCE tab.

How can I copy Eclipse classpath variables from one workspace to a new workspace?

How can I copy the Eclipse classpath variables from the open workspace to a new workspace? I am using Eclipse Juno (Eclipse Platform 4.2.1 and Eclipse Java Development Tools 3.8.2).
Try File -> Export -> General -> Preferences and export All. Next, import the preferences into your second workspace.
Classpath variables are stored in at least three places in eclipse:
Workspace level
These are effectively global, and can be seen in Preferences->Java->Build Path->Classpath variables. You could export these as with any other preferences, and import them to your new workspace.
Project level
Seen in the Project->Properties->Java Build Path editor. These are stored in the .classpath file in the project root. You could simply copy and paste relevant sections from one .classpath file to another if you want to avoid using the project properties editor.
Run configuration
These are classpath variables used to actually execute code from Eclipse, you can see them in Run->Run configurations->(select one)->Classpath tab. You can 'save' a configuration by going to the 'Common' tab and changing it from 'local' to 'shared', and then move that shared file whereever you care to.
Yes, there is no direct way to achieve this. I found a workaround solution.
Try the File System export, select only .classpath files for all the Projects you want to export and in the options select 'Create directory structure for files' to make sure each project classpath is generated in its own folder.
for using this to import, just copy-paste the exported files(containing only .classpath file) to the new workspace.

how to recover a corrupt workspace in eclipse?

I had a corrupt workspace (due to svn collision).
I deleted the .metadata directory from the workspace, and then reloaded eclipse, and did an "import" of a project into the workspace.
However, the project got imported in a rather strange way -- all directories in the project appear, but the src/ directory does not have automatic compilation (when choosing a .java file) -- it is as if the src/ directory is not identified as a special directory.
Is there a way to fix that?
I also followed http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/, and that did not help either.
Switch to a new workspace.
Then go File -> Import -> Exsisting projects into workspace .
In the root folder text box , type the address of corrupted workspace.
Click Refresh .
Select the projects and click finish
All configuration data for your workspace is stored in .metadata. Try to recover the deleted folder then fix the workspace. Otherwise you will need to reconfigure everything.
You can salvage certain folders from .metadata to keep your preferences (e.g. key bindings) at least.
After importing your project, check your project properties, especially the entries in "Java Build Path". There you have to add the "src" directory as source folder. Maybe you also have to adjust the output folder and libraries you are using in your project.
create a new project.
copy your pages ,library files,etc.
set build paths.
compile it. then others will be automatically created
copy project to another (right click -> copy in eclipse)
new project created was correct for me in same situation and .class files repair .

eclipse and SVN adding jar files

I'm trying to make modifications to the trunk found at https://wafle.svn.codeplex.com/svn SVN repository location. The way that I did this in Eclipse was that I used Subclipse, added a new repository location, then opened up the project and right clicked on the trunk. Then I clicked "checkout" and checked it out as a new Java project. Then I found the folder containing the source code that I want to change and recompile and I used Build Path->Make source folder. Next, I realized that I needed 190394994 jar files that were all in different places under the project's "Third Party" folder. So I used Build Path->Configure Build Path in Eclipse, then individually added each jar I needed through "Add External Jars".
My question is; did I do all of this right, and is there something I could have done more easily, such as import all the jars at once instead of individually clicking each?
Thanks.
I'm guessing that you are embellishing a little and didn't add 190 million jar files by hand. (Even at 1 jar click per second, you would be going nonstop for 2,200 days.) Incidentally, you can shift-click and choose many jars from the same directory.
The secret is in the .classpath file; that is where the build path is stored. Someone before you has probably created a fully-orbed .classpath file and stored it in SVN.
If you created this as a new Java project, it will begin with a very simple .classpath with the folder for your project's class files and the JRE. (Apparently, SVN does not overwrite it with the .classpath or you chose not to merge your local version with the one from SVN.)
Next time, you might want to overwrite your project's .classpath with that fully-orbed one on SVN. Refresh and look at the Build Path. They should be all there and in place.
First thing: rajah9 is exactly correct - there is a .classpath file already.
You just got a little hung up on a really odd svn repo layout. the java stuff is mixed in with the .net stuff. Check out the trunk and then do a file > import... then select general > existing projects into workspace. You'll want to select the Source/JNAWindowsAuthProvider/ folder.
There is already a .classpath that references the jars in the ThirdParty folder. (not quite 190 million)
Second thing: when you added the jars as external jars, it makes an absolute path to the jar file. you want to always avoid that, if you hit the add jars button it will be a relative path.

Eclipse does not show lib directory during Java Build Path -> Libraries editing

I have an Eclipse/Java project (Eclipse 3.5.2) that I am trying to add some JARs to. In the root project directory I have 3 sub-directories, src, bin, and lib and all 3 sub-directories are present in the Package Explorer list. I put the needed JARs into lib. However, when I go to Project Propertes -> Java Build Path -> Libraries (tab) -> Add JARs, and the file dialog comes up, it only shows the src and bin directories in the file picker, not the lib directory. I'm guessing it is something really simple, but can someone tell me why the file picker dialog doesn't show the lib directory?
-- roschler
After you copy a jar file to your lib folder, you need to refresh the project in Eclipse (use F5) so Eclipse knows about it.
It will then show you the lib folder in that dialog.
Note: You are correct in your answer that the said dialog doesn't reread the directory structure, but you are missing the point - it is not supposed to. That's what you have "add external jar" for. Further more, Eclipse is trying to be smart and not show you jars that you have already added (think about a folder with 50 jars and you just want to add one). That's why it didn't show you the lib folder - it thought the folder was empty.
This is to help others. I had to do File -> Refresh to get Eclipse to see the files. Apparently file picker dialogs do not reread the disk structure. I guess they are pulling from Eclipse's main file directory image which has to be refreshed before new files are visible anywhere else in the program.
This is how I resolved this problem.
I created a lib folder in my java project.Then I added some jar to lib folder.
But it doesn't appear in my eclipse IDE.Then I selected my project and right clicked on it. Then refreshed.
It works for me. I think this will help you.

Categories