Equivalent of "Order and export" of Eclipse in Netbeans - eclipse

I'm using Netbeans 7.2.1 in Ubuntu 12.10 and I'm trying to change the order of class loading. I have two classes in same package with the same name, but one is in my sources and the other one is in a JAR. The class in my project sources has a higher priority and I want to use it instead of the class in the JAR. In Eclipse I can change the order under the "Order and export" tab in Project Properties -> Java Build Path.
Netbeans seems to priorize JAR classes higher than project sources by default. How do I change the class loading order?

Note: I discovered the answer while I was writing the question and I hope it will be helpful for someone with a similar problem.
Go to Project Properties -> Libraries -> Run and make sure that "Compiled Sources" is above "Classpath for Compiling Sources" by selecting it in the list and clicking "Move Up".

Related

Ordering and Sorting Libraries in Java Eclipse

In Eclipse, on many occasions i have had issues with the order in which libraries and jars of a project are loaded. i.e. Project -> BuildPath -> Configure Build Path -> Order and Export.
I have the following questions:
Are libraries loaded with preference?
If two libraries conflict, which one overrides the other?
Should the src folder be at the top or should it be the JRE System Library. If so, Why? Is this trivial?
Direct answers or references to reading material would be great.
A quick google and I found a good reference about this "Order and Export" tab, from here on stackoverflow.
The "Order and Export" tab in "Java Build Path"
A quick look into that in eclipse and I found that eclipse is only allowing a reordering at library group level, not at library level, as the question was.

F3 on Eclipse doesn't go to the class that was selected

Background
I have multiple android libraries, each has its own classes.
The problem
For some reason, for classes that extend from one of those libraries' classes, when I click F3 to go to the class itself, I get an error:
"The Jar of this class file belongs to container 'Android Dependencies' which does not allow modifications to source attachments on its entries"
What i've tried
I've done some searching of this issue, and found multiple solutions (for example here, here and here), but none has worked for me:
clean project
set the order of the build path to have src at the end, while gen folder is before it.
update ADT, as it was probably fixed.
add "Source attachment", but this is impossible for android libraries (blocked for some reason).
The question
Why does it occur?
How come it's still occuring even on the newest ADT ( i have 22.3.0.v201310242005-887826 )?
Quoting from mik3y In Eclipse, how can I quickly access the source of an "android library project" from the source of a project that uses it?, which worked for me:
Right click on the non-library project (Project B) and select Build Path:
In the Projects tab, add the library project Project A as a dependency.
In the Order and Exports tab, be sure Project A is given higher precedence than the placeholder/bundle Library Projects.
I had to do both of these steps in order to fix this issue, with ADT15, Eclipse 3.7 and new projects.
EDIT:

multi module maven project structure in eclipse

I have two modules under a main project
main
|
|
--module-a
|
|
--module-b
I created it using eclipse->new ->Maven project, eclipse->new->maven module.
The structure in the file system looks correct. But in eclipse, it shows module-a, module-b as two new projects in the package explorer.
My main project looks like this.
I have seen few multi module projects where, the modules are present within the main project in package explorer. The main project had
module-a/src/main/java
module-a/src/test/java
module-a/src/resources/java
module-b/src/main/java
module-b/src/test/java
module-b/src/resources/java.
How do I convert my project to look like this ?
Starting from Eclipse 4.5.M5 (that you can already download at http://eclipse.org/downloads ), the Project Explorer view has a parameter to show projects hierarchically, to better handle such case. See https://www.eclipse.org/eclipse/news/4.5/M5/ for details.
You will find if you navigate the actual file system (oe use the 'navigator' view in eclipse) that the sub modules do in fact exist underneath the main parent project folder.
Eclipse is nice enough (clever enough or whatever) to pull them out when you use the 'package explorer' view. I guess this makes it easier to find and navigate your way aournd a highly modular project.
However if you set up your Parent POM correctly you can have a flat structure to your modular project if you so desire (I haven't as yet been able to get this to work, so far I think it is related to the sub module classpaths or something?).
David.
I solved this problem as follows:
Under the "Project Explorer" click on the "View Menu" (little triangle) and select "Filters and Customization..."
Under the "Content" tab tick "Nested Projects"
Finally, Under the "Pre-set filters" tab tick "Nested Projects: hide folders when projects is shown as nested" and "Nested Projects: hide-top-level project if shown as nested".
By doing that I come up with the following structure.
I used a Spring Tool Suite 3: Version: 3.9.11
Basically, Eclipse does not support the Maven way of structuring projects.
By using the M2E it is possible to execute Maven as part of the build, but that way you lose the project management and incremental build capabilities of Eclipse.
You can also simply use the Eclipse layout in the IDE, and build with Maven in the build server, but that way you have to make sure the two build are identical.
I have seen few multi module projects where, the modules are present
within the main project in package explorer.
Thats what do maven eclipse plugin. It just create single project with multiple source directories for each module of maven multimodule project.
If you want to see some hierarchical structure in eclipse - use working sets. Create working set with name of parent, add module-a and module-b to it and visually it will be separated from other projects in eclipse workspace.
You can do this in earlier versions of eclipse as well. Close and Remove the sub-module projects (as they are already present in the parent folder). Now click on Properties on the main project -> Project Facets -> Convert to faceted form. This will detect Java automatically, Click on Apply, OK. Now you can see that these modules are created with Source folders

How can I get Eclipse to index an entire C/C++ source tree that contains multiple "make projects"?

I'm having trouble getting Eclipse to index my source code. I'm using Eclipse Helios on Windows XP at the moment.
I have a directory called src. Within it, I have a bunch of dirs, something like this:
src
-include (common headers)
-lib
-libIO (source code for this library)
-libGUI (source code for this library)
-pgms
-pgm1 (source code and headers for this pgm)
-pgm2 (source code and headers for this pgm)
Each leaf has its own Makefile. There is no top-level Makefile in src. pgm1 can and does include files from include and lib/libIO and lib/libGUI.
Basically, I want Eclipse to index my entire src directory, without having to set up a C/C++ project for every leaf in my tree. I can't seem to find a way to make this happen.
Here's my symptoms; what I'm trying to solve for:
When editing source in the pgm1 dir, it references functions that are declared in my include dir header files and defined in source files found in lib/libIO.
However, when I press F3 to get to the declaration of a function, Eclipse says "Could not find symbol 'X' in index". I can't seem to get Eclipse to find either the header declaration or the source definition for the method under my cursor (like the Java module does perfectly). Is this possible?
I had exactly same issue as OP but for some reason the menus in Eclipse I was using (Helios Service Release 2) were not "Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.".
The way I fixed the issue was :
in C/C++ view, right-click on top project name;
in the menu, select New->C++ Project;
in the window that appears, select Convert to and then select C++ project;
click OK to close the window.
Eclipse will start indexing right away. Depending on the size of source tree it may take a while but you will have the indexing working finally after that.
I faced similar situation. I solved it in this way: right-click the project in project View-->select Index-->rebuild.
I managed to solve this thanks to comments here.... I ended up recreating my project. I used the Import method to download a project from CVS, and told it to use the New Project wizard to do so. When I got the New Project dialog, I told it this was a C++ Project, and the indexing now works fine.
I still wish I could index files without having to attach a specific project type to it, but at least I found an answer.
Thanks for the help all.
Exit Eclipse. In workspace go to ".metadata/.plugins/org.eclipse.cdt.core" and delete everything in there.
in the project explorer panel, right click the project you want to re-index, then select index, then select the action you want
Indexing of files and variables under different flags is always complicated when we have a huge project, lot of files and more importantly lot of different build options. I prefer playing around with the Indexer option to help me browse the entire code.
You can find it : Project Properties>C/C++ General/Indexer.
You can choose "Enable project specific settings"
Then it's up to you to choose the options you want for your project.
For a particular build we can choose "Use active build configuration" so that only the files and MACROS are considered which are used by the build script.
Or Index all source files in the entire project.
I am using Eclipse Neon 3, here's the solution that worked for me :
go to File
New
Convert to C/C++ Autotools project
then select your project and finish.
It can take some time to finish indexing, it depends on your project size.
I have experienced problems with the indexer of Eclipse Luna when there was an unresolved friend declaration in the class declaration - it seems then that the indexer skipped indexing the rest of that class, and all references to it was shown as unresolved by the indexer.
Solution: removed the unresolved friend declaration (in my case, it was legacy code that was no longer needed).
Please try the following (my project is set up differently, so I am not sure this will work for you).
Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.
Do you see your source folder there?
I observe this behavior:
When I add a source folder and then exclude it from build, it disappears from the above list. After that the folder is no longer indexed. Re-adding it to "Source Location" solves the problem: the folder is now indexed; remains excluded from build (as intended); is visible among source locations.
I believe it is a bug -- excluding a source folder from build should not remove it from source locations list.
In Coocox IDE (Eclipse + gcc) the problem is resolved by going from file menu
Edit > Preferences > C/C++ / Indexer > Build configuration for Indexer set to Active build configuration and the rebuild the project (Ctrl R).
If the project is already converted to C/C++ and still the index is not working you can right click on the project and Index and rebuild. The project will start indexing right away.
I am using
Eclipse IDE for C/C++ Linux Developers
Version: Helios Service Release 2
Build id: 20110218-0911
I followed the suggestions above and in addition I had to mark all referenced projects (with in the work space) using project properties->Project references
The following has worked for me in Eclipse Neon:
New Project -> C/C++ -> Makefile project with existing code -> Next. Then Navigate to the code and finish the project creation. Indexing starts automatically.

Red exclamation mark in Eclipse with mercurial

I have imported a project with Mercurial (hg clone ...).
When opening it with Eclipse, a red exclamation mark appears by the project's name in the Project Explorer, and it cannot be built. Silly messages like "import java.util cannot be resolved" appear, and errors in files are not marked in the Package Explorer.
How can I resolve this?
Check the problem view. By exclamation it is usually means a problem with build path
Check the Build Path of the project by right clicking the project and select Build Path -> Configure Build Path.
One problem I often encountered is different people using different Java SDK and so when the exact SDK is not available in your machine, you need to change to your Java SDK (via JRE System Library -> Alternate JRE). A better way to avoid this problem is to always select the JRE System Library from Workspace default JRE or Execution Environment.
I solved the problem by adding the external .jar file in to my project.
RightClick on the project -> Properties -> Java Build path -> libraries tab -> Add jar
Select your jar file and added it
Thats it the red ! mark gone.
Some times it happens that you have added a jar file earlier but currently not using it. Then after some time you delete the jar file from your system. But since you are not using the library file, so you will not get any error.But then you will see the red exclamation mark for the project. So all you need is to remove the added jar from the Build Path.
Done.....
The Java Runtime Library was defined wrong for the pulled project.
It had to be reset under Project | Properties | Java Build Path | Libraries.
It means there is a problem with the build path in your project. If it is an android project then it mostly means the target value specified in project.properties file cannot be found. This can also be caused because of other kinds of built problems. But it is shown mostly for built problems only. See here for more details. It is about built error decorater seen in eclipse.
An extract from that page:
Build path problems are sometimes easy to miss among other problems in a project. The Package Explorer and Project Explorer views now show a new decorator on Java projects and working sets that contain build path errors:
The concrete errors can be seen in the Problems view, and if you open the view menu and select Group By > Java Problem Type, they all show up in the Build Path category:
I figured out each time i am trying to import a library into my android project, i have a red exclamation mark with both ActionBarSherlock and Facebook libraries
This is how i solved it:
After adding the library into your project "project properties->Android->Librairy->add"
If you are using Eclipse, all you have to do is to clean your project and build all your workspace:
"project -> clean... -> "clean selected project" -> build the entire workspace
For me, the problem was a simple one - the reference project was compiled in 1.5 and my project 1.6. Matching the two solved the issue.
Right-hand-click on the project, select properties, select java compiler.
This is how I solved this problem:- Right-Click to project->properties->Java Build Path->Libraries(tab)->Remove the Jar which is already present there with a Path given along.