Eclipse class navigation in package/navigator explorer - java

Is there a plugin in eclipse where when i switch on a open class on eclipse, it will highlight that class name in package explorer or navigator. So i don't want to manually check the package declaration and explore it in package explore or navigator?

first you should check which version of your eclipse, if you version is Java EE dev, then it has this function. just click the button which is 2 arrows that in the top of package explore or navigator, then you see when you change the file in editor, then the package explore or navigator explore will focus on the file that you select in editor.

Not automatic but you can use Alt-Shift-W to open "Show in..." giving you options to show it in either Navigator, Package Explorer, etc.

Related

Duplicate src packages when importing an existing project in Eclipse

When I try to import an existing project into eclipse,
I see duplicate packages for src folder(highlighted in red below)
Not sure why.How do i fix this?
This is not an issue, actually It's fine.
Eclipse displays the package view (as you pointed in the first red square) and also the directories inside your project (the second square).
As you can see in your screenshot, the first 3 folders contain the package icon (that's because you are using the Package Explorer view), then below your Maven dependencies you can find the physical folders.
If you don't want to see your package folder you may consider using Navigator view instead of Package Explorer.
Btw, you can configure filters for your view by using:
Then select the filter you consider appropiated.

How to go into a class in eclipse?

This is how my current file looks. Is there a command or shortcut to go to the actual Java file of crud repository? (I wanna see what that class looks like) I tried hovering over it
but crud repository wasn't clickable.
You can do that by holding ctrl and clicking on it.
Seems you are just starting with Eclipse IDE. Have a look.
Hold Ctrl and Click on the Class Name
If you get error as "Source not found"
Use "Attach Source" button to add the source zip or folder.
ctrl-click on the name, you need the sorce of the file or you will see a decompiled version of the class
for open source project, or where you can get sources, you can add the jar of the sources or a folder to the library definition

Could not find or load main class Eclipse

I am new to JAVA. I am using Eclipse 3.7 with WindowBuilder Pro installed. I have made a JFrame SearchFrame.java using the GUI in the package SearchPackage.
But when I try to run this file it gives me the error:
Error: Could not find or load main class SearchPackage.SearchFrame
I looked into my output folder DatabaseSearch/bin and there is no .class file in it. Please suggest me what should I do to rectify this. Thanks in advance.
This worked for me
Try to:
Right click on the Project in PackageExplorer -> Properties -> Java Build Path
Select Order and Export tab, and move the source package that contains the main class to the top, by selecting the correct package and pressing the Up button.
Click right at project at Package Explorer the compile and run/
Automatic builds may be disabled preventing the class file from being generated. Right click on
DatabaseSearch > Build Project
to use the manual build feature
Please clear all the build errors if any in your project. May be the project has some missing jars as a result its not able to form .class file out of your java.

The import com.google cannot be resolved?

I am using a tutorial at this page:
http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
It tells me to change the main activity, everything is going well except for this error:
"The import com.google cannot be resolved"
The line highlighted is:
import com.google.android.c2dm.C2DMessaging;
What could be the problem? Should it be my project name instead of com.google? Because I have a java file that is Web.SMS.C2DMessaging.
Did you add c2dm.jar to your project's build path?
First copy the c2dm.jar to lib folder in your project (create one if there are none).
1.) Right click on your project and select Properties.
2.) Select Java Build Path and select Libraries tab.
3.) Click Add External JARs... button and choose the c2dm.jar from lib folder.
4.) Click Open and OK.

how to open jar selection dialog at the eclipse pulgin code

At Project > Properties > Java Build Path > Libraries tab
you click Add Jars button, you will see the JAR Selection dialog.
I like to open this JAR Selection dialog on my plugin code.
How to open this?
With the Eclipse RCP edition (which you must have since you are developing a plugin), you can use the Plugin Spy (Alt+Shift+F1) and see what exact class you need:
alt text http://img541.imageshack.us/img541/2232/eclipsetreesel.png
It is based on org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog (strangely absent from the sources of org.eclipse.jdt.internal.ui.viewsupport), derived from org.eclipse.ui.dialogs.ElementTreeSelectionDialog.
If you want to see how it is opened, you need to have a look to the global window opening that dialog:
alt text http://img41.imageshack.us/img41/1903/eclipselibclass.png
It is the org.eclipse.jdt.internal.ui.preferences.BuildPathsPropertyPage, from which you can infer the various action classes associated with the button and see how it works.

Categories