Say you're working on a Java project in Eclipse and you're looking at a import
statement like:
import com.somefirm.somepackage.AClass;
and the classpath for the project has a million and one .jars on it.
How do you determine where the import is coming from?
You can use CodeSource#getLocation() for this. The CodeSource is available by ProtectionDomain#getCodeSource() .
Select mymethod() and press ctrl + alt + h . To see some detailed Information about any method you can use this by selecting that particular Object or method and right click. you can see the "OpenCallHierarchy" ( Ctrl + Alt + H ).
To enable this, go to Windows -> Preferences -> Java -> Editor -> Save Actions and then enable Perform the selected action on save -> Organize imports. After this, whenever you save a java file, eclipse will remove the unused imports automatically.
Open declaration (F3) on the import line. This will open the Java or Class file that the import resolves to.
Once that files is open, you can right-click on the declared type and choose "Show In->Package Explorer" to see where it is declared.
Alternately, if "Link with Editor" is selected in Package Explorer, the related package/jar will already be open for your inspection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With