Can eclipse prevent you from using particular classes? - java

For example,
I don't want to use org.testng.v6.Maps, (I want com.google.common.collect.Maps)
I don't want to use org.hibernate.mapping.List, (I want java.util.List like everyone else!)
Is there a way to tell Eclipse not to suggest these in the autocomplete box?

Yup - I have exactly this problem at work for a few classes too.
Preferences -> Java -> Appearance -> Type Filters.

Re-arrange your dependencies in the library path according to the order you want them to be.
Right click on project > Properties
Java Build Path
Order and Export tab
This should give priority to the dependencies you do prefer. (Although on second thought I am not sure this is reflected in the auto-complete boxes.)

Related

Project order Eclipse project explorer view

Is this possible in eclipse to put project in order like order by name or order which i would like to add.
I have around 30 projects in eclipse i want to see them with some order like alphabetic order. Is this possible in eclipse?
You can follow these steps to rearrange your project:
Window-> preferences -> General -> workspace -> Build order
Here you can rearrange the project build order but you can not define any rule like 'All project should come in Alphabetic order'.
For more clarification visit: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-17.htm
you can define "Working Sets" (i.e a named group of projects) that can be ordered. But I think you cannot reorder the projects within those working sets (at least I've never seen such an option).
Edit
for information about the general usage of workingsets you may want to visit one of the following URLs:
http://www.vogella.com/articles/Eclipse/article.html#tips_workingsets

Remove autogenerated Javadoc comment eclipse

Is there any way to remove the annoying "#Javadoc" comments that eclipse generates with every new class?
I tried to remove it in the preferences but i dont get it
Take a look at the Settings of your Eclipse.
Window->Preferences than go to Java->Code Style -> Code Templates and change the Comments at Files. You can also change every style for Method and so on.
regards

Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar

I am trying to modify some legacy code from while back and getting the following kind of errors:
Access restriction: The method create(JAXBRIContext, Object) from the type Headers is not accessible due to restriction on required library ..\jre\lib\rt.jar
for these import statements:
import com.sun.xml.internal.bind.api.JAXBRIContext;
import com.sun.xml.internal.ws.api.message.Header;
import com.sun.xml.internal.ws.api.message.Headers;
import com.sun.xml.internal.ws.developer.WSBindingProvider;
Been searching what this might mean and how to fix it, however not been able to find a clear answer. Some posts seem to suggest that I have some JARs included that implement classes that are now available as part of the core java distribution, but as far as I can see none of the JARs I include contain different/older versions of the above classes.
Anyone able to tell me what this error is all about and how I might go about fixing this?
Thanks for your help already in advance,
Olli
I ran into something similar, I think that the cause of the warning is Eclipse trying to discourage you from using the internal com.sun packages that are installed as part of your workspace JRE but which are not part of the public Java API.
As Justin says in his answer, changing your compiler settings can hide the warning. A more fine-grained approach is to modify your build path to explicitly allow access to the package in question:
Open the Libraries tab of the Java Build Path project property window.
Expand the JRE System Library entry.
Select "Access rules" and hit the Edit button.
Click the Add button in the resulting dialog.
For the new access rule, set the resolution to Accessible and the pattern to "com/sun/xml/internal/**".
After adding this access rule, your project should build without these warning.
Excellent answer already provide onsite here.
See the summary below:
Go to the Build Path settings in the project properties.
Remove the JRE System Library
Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
Not a true solution, but everywhere I looked the solution suggested was to simply tell Eclipse that those aren't errors. You can change it by going to Properties --> Java Compiler --> Errors Warnings --> Deprecated and restrited APIs --> Forbidden reference (acess rule), Change it from Error to Warning or Ignore.
i've solved this issue with these steps: expand your project, right click "JRE System Library" > Properties > choose 3rd option "Workspace default JRE" > OK . Hope it help you too
In Eclipse:
Project -> properties -> java Build Path -> libraries
Remove existing JRE System Library, then Add Library -> JRE System library -> next -> ok
Error will be removed.
I had the same problem when my plugin was depending on another project, which exported some packages in its manifest file. Instead of changing access rules, I have managed to solve the problem by adding the required packages into its Export-Package section. This makes the packages legally visible. Eclipse actually provides this fix on the "Access restriction" error marker.
In the eclipse environment where you execute your java programs, take the following steps:
Click on Project just above the menu bar in eclipse.
Click on properties.
Select libraries, click on the existing library and click Remove on the right of the window.
Repeat the process and now click add library, then select JRE system library and click OK.
I'm responding to this question because I had a different way of fixing this problem than the other answers had. I had this problem when I refactored the name of the plugins that I was exporting. Eventually I had to make sure to fix/change the following.
The product file's dependencies,
The plugin.xml dependencies (and make sure it is not implicitly imported using the imported packages dialog).
The run configuration plug-ins tab. Run As..->Run Configurations->Plug-ins tab. Uncheck the old plugins and then click Add Required Plug-ins.
This worked for me, but your mileage may vary.
I just changed project facet to 1.7 and it worked.
Go to Buildpath
Remove Existing JRE and add new JRE library which contain Jdk1.6
and finish
Now clean all project and build again
I think this way you can resolved your error

Load Insubstantial Swing Plugins to Eclipse

How do I load the Insubstantial Swing plugins to Eclipse?
I refer to the plugins here: http://insubstantial.posterous.com/
A simple solution would be to copy the jars into your project and add them to the build path (under "Properties->Java Build Path->Libraries"). If you want to use them in several projects and configure the source and javadoc attachments only once, then you might want to define a User Library for them (See the "Add Library" button on that same page).
Windows Builder allows you to apply any look and feel you want. So, you should be able to add Substance:
http://code.google.com/javadevtools/wbpro/preferences/swing/preferences_lookandfeel.html
Depending on what exactly you want to do, you may still have to do some customization in code.

Node.getTextContent() is undefined in Node

In my project I am facing a problem stating
The method getTextContent() is
undefined for the type Node
I am currently using jdk 1.5, can anybody tell me what this is about.
If you are getting this problem in Eclipse, my tested solution would be:
Java Build Path → Order and Export, select JRE System Library and move it to Top
Java Build Path -> Order and Export tab, selected the JRE. Clicked the "UP" button to move it to the upper.
As there are lot of class named Node in the JVM, I would say that you imported the wrong one. Check your imports, verify this is the class you really want to use and try again.
If you are getting this problem in eclipse IDE then fix it by doing :
Right click project, select Properties -> Java Build Path.
Though we will eventually need to use the "Order and Export" tab, it's a very long list, and there's actually a shortcut to finding the xml-apis-1.0.b2.jar file we want to move. Go to the Libraries tab which lists things alphabetically. Scroll down the the x's and single click that entry. Don't click the checkmark, just the name.
Now switch back to the Order and Export tab scroll down, you'll notice that library is still highlighted, pretty cool!
Click the Bottom button on the right, to move it all the way down. It should show up AFTER the special "JRE System Library [JVM ...." entry. And it should not have a checkmark.
follow below link more help:
http://www.enterprisesearchblog.com/2009/09/fix-for-gettextcontent-is-undefined-for-the-type-node-for-solr-project-in-eclipse-ide.html
You are probably having your project settings (assuming you are using Eclipse or some other IDE) to Java 1.4. Java 1.4's org.w3c.dom.Node class does not have that method (it was introduced in Java 5).
You, or the code you are using, is calling a method called getTextContent() which is not defined for the Node Object. The explanation by the compiler is pretty good in this case.

Categories

Resources