Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find text in decompiled jar files with Jetbrains IDES

I'm with Jetbrains IntelliJ (or Android Studio if you prefer), and my project is built with gradle and some external java libraries from my company namespace. Thing is that is difficult to navigate trough classes as i cannot search text into the .jar files or resolve usages.

Do you have any idea of how to do this?, is there a plugin or something? a trick maybe?

Many thanks.

like image 730
R01010010 Avatar asked Aug 20 '15 11:08

R01010010


People also ask

How do I search for text in a class file in IntelliJ?

From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F . In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . IntelliJ IDEA places the highlighted string into the search field.

Can jar files be decompiled?

How do I decompile a JAR file? It is just a ZIP file, so to extract all the files with regular zip tool. Then to decompile the classes (inside the ZIP) use a decompiler.


1 Answers

IntelliJ IDEA (as of 2017.2 or newer) knows how to decompile JAR files with no source attached, that is when you are in debug mode and you jump into the implementation. However this will not allow you full text search (such as looking for usages).

If it's just 1-2 JARs that you care for browsing, you may manually edit your Module properties in IntelliJ and add the source JAR files (that you need to download from your Library's website along with the binary JARs).

Another option is to use Maven, and have it download the source alongside with the binaries from the public Maven repository (if we're talking about open source libraries).

Yet another option, in an enterprise setting someone typically sets up an Artifactory (for instance https://www.jfrog.com/artifactory/ ), which is source for all the libraries and their source code.

If you use some up-to-date build script (for example Gradle), you can build an IntelliJ project with all the sources already linked in.

Hope this helps!

like image 173
blackbird Avatar answered Oct 19 '22 11:10

blackbird