Scala is unable to execute code successfully.

Asked 1 years ago, Updated 1 years ago, 306 views

After setting up the scala development environment and executing the following code,
There is an error and it cannot be executed properly.
How can I start it well?

object Hello {
  defmain(args:Array [String]):Unit={
    println("Hello, World!")
  }
}
"C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51940,suspend=y,server=n -javaagent:C:\Users\Owner\AppData\Local\JetBrains\IdeaIC2021.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\charsets.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\cldrdata.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\dnsns.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\jaccess.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\localedata.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\nashorn.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\sunec.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\sunmscapi.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\ext\zipfs.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\jce.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\jfr.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\jsse.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\management-agent.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\resources.jar;C:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\jre\lib\rt.jar;C:\Users\Owner\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.8\scala-library-2.13.8.jar;C:\Program Files\JetBrails\IntelliJ IDEA Community Edition 2021.3.2\lib\idea_rt.jar "Hello
Connected to the target VM.Address: '127.0.0.1:51940', Transport: 'Socket'
Error: Main class Hello not found or could not be loaded
Disconnected from target VM.Address: '127.0.0.1:51940', Transport: 'Socket'

Process terminated with exit code 1

scala

2022-09-30 22:03

1 Answers

It seems that the problem was that there was no scala code in the main/scala directory.
I put the scala code in the main/scala and it worked.

Enter a description of the image here


2022-09-30 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.