EAST RUTHERFORD, N.J. - The rock band Bon Jovi surprised graduates and guests at Fairleigh Dickinson University's commencement exercises Tuesday by putting on an impromptu performance.

Fairleigh Dickinson won a nationwide contest to bring the New Jersey-based band to play their graduation by generating the most interest on social media.

Jon Bon Jovi, who was born and raised in Sayreville, New Jersey, spoke to the graduates before the band performed “Reunion,” a song about a class gathering years later to share memories of their lives.

“Today marks the end of one chapter in your life and the start of another,” he said from a stage at MetLife Stadium in East Rutherford, where the band has played to sold-out crowds many times. “Enjoy the book; you're the one writing it.

“Don't take anything personally. Accept both praise and criticism equally, but take neither to heart. There are many surprises awaiting you on the journey.”

The contest was run by MTVU, and asked students across the country to tweet their best college moments with the hashtag #JBJReunionContest.

“Reunion” was first performed by Bon Jovi in 2015 at the commencement exercises for Rutgers University, and appears on the band's current album “This House Is Not For Sale.”

Most of the students did not know Bon Jovi would be appearing until they were already inside the stadium, home field for the NFL's Jets and Giants. Although best known for '80s-era hits like “Livin' On A Prayer,” ”You Give Love A Bad Name“ and ”Wanted Dead Or Alive,“ Bon Jovi's current album went to No. 1 on the charts and they were the top-selling live band in the U.S. for the first three months of 2017, making them popular with students whoseparents watched the band on MTV decades ago.

Iman Suleiman of Garfield, said she loves Bon Jovi because his music was featured on an episode of her favourite TV show, “Glee.”

“Our generation is one of the last generations that love Bon Jovi,” added Isabelle Nemeh, of Wayne.

And Jessica Awad, of Wyckoff, enjoyed Bon Jovi, even though she had someone else in mind.

“I would have preferred Justin Bieber, but it(s still cool,” she said.

In an interview inside the Giants locker room before the ceremony, Jon Bon Jovi told The Associated Press he hopes the graduates remain flexible about their plans.

“Whatever your vision of how your life is going to be going forward, do it in pencil,” he said. “The great thing is the journey is about to begin. You may take some turns along the way that may take you to somewhere you never even dreamed of going. It's a great journey.”