Reputation: 2928
I have upgraded a couple of days ago to eclipse 4.2, and am working on a project that is tracked by git using the eGit plugin.
Suddenly, I think it must have been right after a commit with a push, the automatic import hints have completely forgotten about the classes of my project. All it can give hints for are the java standard library classes.
I've tried restarting eclipse, as well as cleaning the project, validating it, performing a pull, and looking at the .classpath file (which didn't look particularly odd to me).
If you look at the screenshot; in the package explorer you can see a class listed named SceneNode". On the right there is a file I was working on, which is in the same project, but which is missing the import option, which should be there.
Manually writing the import statement fixes the problem, but since I'm lazy I want my import options back. Has anyone else had this problem?
edit: here's my .classpath file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="jars/jinput.jar"/>
<classpathentry kind="lib" path="jars/lwjgl.jar">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="ORRE-v2/natives"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/lzma.jar"/>
<classpathentry kind="lib" path="jars/slick-util.jar"/>
<classpathentry kind="lib" path="jars/slick.jar"/>
<classpathentry kind="lib" path="jars/xom-1.2.8.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="jars/lwjgl_util.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Upvotes: 7
Views: 18542
Reputation: 21
From the comments (edited for grammar):
I have searched a lot, but I think you should try the Eclipse shortcut to fix all imports - Ctrl+Shift+O – vicky
I couldn't find Other Java Proposals; however trying the above worked for me.
Upvotes: 2
Reputation: 1
Go to "Preferences » Java » Editor » Content Assist" Under "Insertion, Add import instead of qualfied name":
Uncheck "Use static imports".
I was coding:
FileInputStream instm = new FileInputStream(configpath);
Now Eclipse suggests import java.io.FileInputStream;
.
Upvotes: 0
Reputation: 1
If the issue arises automatically then just restart the eclipse it will work.
Upvotes: 0
Reputation: 51515
Updating @vicky's answer for 2020, in Eclipse, to activate the automatic creation of imports for Alexa skills, make sure on the Windows -> Preferences -> Java -> Editor -> Content Assist -> Advanced, that all of the Java options under the Default Proposal Kinds are checked.
Upvotes: 1
Reputation: 591
Try this:
Go to Preferences » Java » Editor » Content Assist » Advanced.
Make sure Other Java Proposals is ticked/checked.
If that does not work simply close the project and reopen it.
Upvotes: 3