Expand my Community achievements bar.

SOLVED

AEM - Issue while executing java class from Bracket IDE editor

Avatar

Level 4

Can anyone please help.

i have created a training project package and imported in Brackets IDE , synchronization is sucessfull to AEM and i am able to export back to AEM.

all statement is executing except java class , i am not seeing any error also.

AEMhtmlpreview.PNGHTML AEM UI Page

JAVA Class file

javaclass.PNGJAVA CLass file

HTML File

htmlpage.PNG

1 Accepted Solution

Avatar

Correct answer by
Employee

... Did you compile the code?

It doesn't look like it.

From the screenshot -- on the left side in the structure pane -- you can't just put .java files inside the content repository and expect it to run. That's not how this works.  Java source needs to be compiled into its CLASS file and those are all magically assembled into a JAR file (an executable program) that adheres to the OSGI specification so it can run inside AEM.

Your Java code needs to be in an AEM maven project and compiled into a deployable artefact.

Start here : GitHub - adobe/aem-project-archetype: Maven template to create new Adobe Experience Manager (AEM) pr...

The WKND Tutorial is also a good resource to understand how to develop in AEM.

WKND Tutorial Overview

View solution in original post

7 Replies

Avatar

Correct answer by
Employee

... Did you compile the code?

It doesn't look like it.

From the screenshot -- on the left side in the structure pane -- you can't just put .java files inside the content repository and expect it to run. That's not how this works.  Java source needs to be compiled into its CLASS file and those are all magically assembled into a JAR file (an executable program) that adheres to the OSGI specification so it can run inside AEM.

Your Java code needs to be in an AEM maven project and compiled into a deployable artefact.

Start here : GitHub - adobe/aem-project-archetype: Maven template to create new Adobe Experience Manager (AEM) pr...

The WKND Tutorial is also a good resource to understand how to develop in AEM.

WKND Tutorial Overview

Avatar

Employee

Actually I'm going to correct myself as I believe you can have Java classes that extend WCMUsePojo within the content repository.

Avatar

Community Advisor

Hi arunk85184451

I have checked this using aem bracket plugin. I can properly see Java classes in Sync status of bracket.PFB the screenshot

Screen Shot 2019-10-31 at 12.03.36 AM.png

Could you please check it again making sure to use the latest version of Bracket and AEM plugin?

Regards,

Arpit Varshney

Avatar

Level 4

thanks arpit

yes i can see the same its getting exported correctly from Bracket to AEM

1849304_pastedImage_0.png

the moment i give the java class reference in html component of the page i.e it displays the output before the java class reference and stops

1849306_pastedImage_2.png

1849305_pastedImage_1.png

any help on this to debug will be helpful

thanks

Avatar

Community Advisor

There is an issue with your HTL code.

Please refer below for correct code -

<div data-sly-use.logic="${'Logic' @value1='Adobe', value2='Systems'}">${logic.message}</div>



Arun Patidar