How to start AEM in debug mode on Windows, Linux and MacOS
Before we start, we need to install the AEM on our machine. To do this, rename the jar file to aem-author-p4502.jar and run it with the command:
java -jar aem-author-p4502.jar
And so now we have everything we need! I will use the standard start.bat file for Windows and start for Linux/MacOS, which are under crx-quickstart/bin. This will give us a handy startup file and you won't have to remember all the commands all the time.
Start AEM in debug mode on Windows
As I mentioned before, take the file crx-quickstart/bin/start.bat. Create a copy of it and rename it as you like, e.g. start-debug.bat.
Here on line 12 we can change the port on which we will run our instance, I leave it as it is:
if not defined CQ_PORT set CQ_PORT=4502
Here in line 19 we can add the necessary runmodes separated by commas, I will leave it as it is:
if not defined CQ_RUNMODE set CQ_RUNMODE=author
Line 25 contains the parameters we are directly interested in. Let's add here the following:
And so line number 25 will look like this:
if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xms4G -Xmx4G -Djava.awt.headless=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Our file to start AEM in debug mode is ready. It is enough to place it under crx-quickstart/bin/ and run it by double click. This will open a terminal window, which will display all necessary information about starting and running the instance.
To stop the process, just press Ctrl+C or run the default file stop.bat, also under crx-quickstart/bin/.
Start AEM in debug mode on Linux and MacOS
We will use the start file located under crx-quickstart/bin/. Create a copy of it and rename it as you like, e.g. start-debug.
Here on line 13 we can change the port on which we will run our instance, I leave it as it is:
Recommended by LinkedIn
CQ_PORT=4502
Here in line 24 we can add the necessary runmodes separated by commas, I will leave it as it is:
CQ_RUNMODE='author'
Line 34 contains the parameters we are directly interested in. Let's add here the following:
And so line number 34 will look like this:
CQ_JVM_OPTS='-server -Xms4G -Xmx4G -Djava.awt.headless=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
Our file to start AEM in debug mode is ready. It is enough to place it under crx-quickstart/bin/ and run it by double click. All necessary information about starting and running the instance will be in the crx-quickstart/logs/stdout.log.
To stop the process it is necessary to run the stop file, which is also under crx-quickstart/bin/.
Note: This guide is suitable for both Linux and MacOS. But if you have issues with the executable files on Linux, you can rename our startup file to start-debug.sh and run it through the terminal using the command:
sh start-debug.sh
Note: Also, if you want to get all information about the instance's startup and operation in the terminal you can do the following:
# (
# (
# java $CQ_JVM_OPTS -jar $CURR_DIR/$CQ_JARFILE $START_OPTS &
# echo $! > $CURR_DIR/conf/cq.pid
# ) 2>&1 | tee -a $CURR_DIR/logs/stdout.log
# ) &
java $CQ_JVM_OPTS -jar $CURR_DIR/$CQ_JARFILE $START_OPTS
Now you will have the possibility to terminate the process with Ctrl+C for Linux and Cmd+. for MacOS. But the PID of the process will not be recorded and you will not be able to stop it with the stop file.
If you have any questions or comments, feel free to leave comments.