0

I am using the Scala IDE. I have created one Scala project and wrote simple scala object i.e.

object Test {
 def main(args: Array[String]): Unit = {
eprintln("hi")
}}

It's running as expected.

After that I have converted my project to a maven project.

I did Clean and install.

after that if I am trying to run my scala class, I am getting below error:

Error: Could not find or load main class Test  

How can I solve this?

Idos
  • 15,053
  • 14
  • 60
  • 75
Sai
  • 1,075
  • 5
  • 31
  • 58
  • What did you do to convert it? What does your file structure look like? Please post your `pom.xml` – Simon Feb 15 '16 at 08:33
  • Does your `package` match the folder structure of your Main? Somehow Eclipse has issues if it doesn't match – Pim Verkerk Feb 15 '16 at 10:26
  • JavaTriang 0.0.1-SNAPSHOT src src **/*.java maven-compiler-plugin 3.3 1.7 1.7 – Sai Feb 15 '16 at 10:35
  • Hi Pim, Can you please explain elaborately. – Sai Feb 15 '16 at 12:50
  • In Java if a class is in `package x.y.z` it must also be in `src\main\scala\x\y\z` for it to compile. In scala this is not a requirement. So you can have a class in `package x.y.z` and put the source file in `src\main\scala\x\y` and it will still compile successful. However if this is your main class Eclipse will not be able to recognise it a class containing a main. – Pim Verkerk Feb 15 '16 at 14:38

0 Answers0