Expand my Community achievements bar.

SOLVED

How extract source code from AEM bundle or Jar

Avatar

Level 2

Hi team,

Kindly suggest what is the best practice to extract source code from  jar or AEM bundle. 

 

Thanks

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @upendarme1 

 

I just want to add a note indicating that decompiling a JAR file can have legal implications depending on several factors, including the software license, and how you intend to use the decompiled code. So just be aware of that. Other than that, a bundle is just a normal JAR (with extra metadata) that can be treated like others have already replied.



Esteban Bustamante

View solution in original post

4 Replies

Avatar

Level 1

You can use java decompiler and drop the bundle jar to see folders https://java-decompiler.github.io/ or JD-Eclipse is a plug-in for the Eclipse IDE which serves the same purpose.

Avatar

Community Advisor

Hello @upendarme1,
First, you can download the jar from AEM, for that

  • Get the bundle Id of the bundle from http://localhost:4502/system/console/bundles
  • Go to folder navigation "crx-quickstart/launchpad/felix/bundle<ID>", where ID is the bundle ID you got from the first step.
  • You will findbundle.jar file under Version*.* directory- That is the jar file location for the bundle ID

Then you can use any decompiler tool to see the Java codes. for that, you can find some tools - https://medium.com/@aashupel2023/the-best-java-decompilers-online-in-2023-517bf6f4971f 

After that, you can copy and paste the original code and write your custom code.
Need to understand before customizing the code, how the bundle was previously executed by AEM.
The best approach for a large customize or bug jar is to create a separate AEM project to maintain this in the future. For smaller you can keep you project codebase in separate package.

Avatar

Level 2

There are multiple ways of doing it.

One way is to use this site http://www.javadecompilers.com/ and upload the jar and you can see all the classes available in jar/bundle. But Decompiled code will not be having any comments or inputs given in comments by code developer.

Avatar

Correct answer by
Community Advisor

Hi @upendarme1 

 

I just want to add a note indicating that decompiling a JAR file can have legal implications depending on several factors, including the software license, and how you intend to use the decompiled code. So just be aware of that. Other than that, a bundle is just a normal JAR (with extra metadata) that can be treated like others have already replied.



Esteban Bustamante