A man pleaded guilty Thursday to murdering a passenger and trying to kill two others in a random knife attack on a shinkansen bullet train last year.

Ichiro Kojima, 23, slashed Kotaro Umeda with a knife and machete, killing the 38-year-old from Hyogo Prefecture. He also seriously wounded two women in their 20s in the attack on the Nozomi 265 train en route from Tokyo to Shin-Osaka on the evening of June 9, according to the indictment.

"I did it with the intent to kill," said Kojima in the first court hearing in his lay judge trial held at the Odawara branch of the Yokohama District Court.

Prosecutors said Kojima found it too difficult to live on his own and "wanted to go to prison" as he had been homeless and sleeping outdoors, including in a park in Nagano Prefecture.

Kojima, who did not have a good relationship with his parents, quit work due to stress and lived with his grandmother until he left her home in Okazaki, Aichi Prefecture, in December 2017, prosecutors said.

He underwent a psychiatric examination over a four-month period before prosecutors ruled him fit to face a criminal trial and indicted him in November last year.

Prosecutors are scheduled to make their closing arguments on Dec. 9 and the ruling is expected to be handed down on Dec. 18.

(Photo shows a car of the Nozomi shinkansen bullet train at JR Odawara Station in Odarawa, near Tokyo, on June 9, 2018, after a knife rampage by a man on the train.)

A long queue formed for the 35 public gallery seats available in the courtroom. A 58-year-old woman from Yokohama said, "This case was shocking as I use shinkansen often. I'd like to hear the accused's account to learn why it happened."

While operators often boast of the safety of bullet trains, with no fatalities caused by derailments or malfunctions in their decades of service, a few serious crimes have been committed aboard the trains.

In June 2015, a 71-year-old man died after setting himself on fire on a train on the Tokaido Shinkansen Line. A female passenger was also killed in the blaze.

The stabbing incident prompted shinkansen operators to make available to police and other security personnel shields and stab vests. Also, an increased number of security cameras were installed to allow for more stringent monitoring and patrols at stations and on trains were increased.

However, Central Japan Railway Co., the operator of services on the Tokaido Shinkansen Line, ruled out implementing luggage screening due to the inconvenience it would cause.

As Tokyo readies to host the 2020 Olympic and Paralympic Games, the transport ministry has tested at some subway stations the use of body scanners to detect dangerous objects hidden beneath passengers' clothing.

In an effort to implement tighter security measures on public transport, the government banned passengers from carrying unsheathed knives on trains, buses and taxis from April this year.

Related coverage:

Police instructor stabs officer with knife in training gone wrong

Suspect's motive for Kawasaki knife attack remains unclear