Could not find or load main class

1,198 views
Skip to first unread message

Dylan Su

unread,
Dec 29, 2016, 7:49:17 AM12/29/16
to Scala IDE User
Hello everyone,
I download scala IDE and try to run HelloWorld but failed with Could not find or load main class.
I run the command 
mvn archetype:generate -DarchetypeGroupId=net.alchim31.maven -DgroupId=com.dylan -DartifactId=test -DarchetypeArtifactId=scala-archetype-simple -DarchetypeVersion=1.5 -Dversion=1.0-SNAPSHOT
to start a new scala project.
Then I use sbt or run mvn eclipse:eclipse to generate .project file.
At last, I try to run HelloWorld through IDE but it always failed.
It seems my code is fine because after I run command
mvn install 
Then I run HelloWorld through IDE will work successfully. But run "mvn install" whenever I do little change to the code seems not a good solution.
It seems scala IDE doesn't compile the project or place the .class file to another dir but it could not find?
What should I do?

Thanks,
Dylan

wpopie...@virtuslab.com

unread,
Dec 29, 2016, 9:51:23 AM12/29/16
to Scala IDE User
Hello,

I see than if you are using command `mvn eclipse:eclipse` the project does not have Scala nature added by
right_click_on_project -> Configure -> Add Scala Nature
then you get project compilation errors because default scala version is 2.11.8 and your example uses libs of version 2.10.x. So next step is
right_click_on_project -> Scala -> Set the Scala Installation and choose `Latest 2.10 dynamic`
and you will still suffer with compilation problems so you need to edit your .classpath file and remove `including="**/*.java" ` from all classpathentries

Then we are almost done but still there is a problem with compilation because Zinc compiler is not able to compile the bridge (whatever it is) for 2.10.6. Looks like bug in Zinc but I have to verify it.
Meantime you can start with
mvn archetype:generate -DarchetypeGroupId=net.alchim31.maven -DgroupId=com.dylan -DartifactId=test -DarchetypeArtifactId=scala-archetype-simple -DarchetypeVersion=1.6 -Dversion=1.0-SNAPSHOT

and do steps:
right_click_on_project -> Configure -> Add Scala Nature
edit your .classpath file and remove `including="**/*.java" ` from all classpathentries

Regards
W.

Dylan Su

unread,
Dec 29, 2016, 12:06:33 PM12/29/16
to Scala IDE User
Thank you very much for the reply and after change -DarchetypeVersion from 1.5 to 1.6. It works fine.
Although it's maybe difficult to use 2.10.x and most of our environment is 2.10.x but 2.11.8 won't be a critical problem.
And between sbt and maven which will you recommend generating the .project and .classpath file?
Thanks,
Dylan

Rafał Krzewski

unread,
Dec 29, 2016, 1:00:22 PM12/29/16
to Scala IDE User
SBT is used by most Scala developers, so I'd go for that.
If you have reasons to use Maven, I'd recommend using http://www.eclipse.org/m2e/ together with https://github.com/sonatype/m2eclipse-scala
eclipse:eclipse has been deprecated in favor of m2e about a decade ago ;)

Cheers,
Rafał

KevinClouderan

unread,
Feb 10, 2017, 1:33:37 AM2/10/17
to Scala IDE User
Hello - 

I am having a similar problem.  Running the latest version of the ScalaIDE.  I have created a template project which I host on GitHub.  I pull the project in, it has just a simple Spark WordCount program.  Then, I go and add some other Spark code written in Scala.  Once I do that, nothing compiles:  I clean the project, etc., have checked my src paths, etc. but nothing works.  What is going on?  Shouldn't compiling code be something I can rely upon with my IDE?

Thanks,
Kevin

wpopie...@virtuslab.com

unread,
Feb 13, 2017, 3:07:46 AM2/13/17
to Scala IDE User
Hello,
could you show me it?

W.

Kevin D'Elia

unread,
Feb 13, 2017, 6:47:27 AM2/13/17
to scala-i...@googlegroups.com
I deleted the project but can share the GitHub code, if you like.

--
You received this message because you are subscribed to a topic in the Google Groups "Scala IDE User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-ide-user/5w7pEGECq5k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-ide-user+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/3a3fa7d4-2aa0-423c-89ca-4fa303f5b757%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kevin D'Elia
US-Maryland-Remote

wpopie...@virtuslab.com

unread,
Feb 13, 2017, 7:00:02 AM2/13/17
to Scala IDE User
sure
To unsubscribe from this group and all its topics, send an email to scala-ide-use...@googlegroups.com.

Kevin D'Elia

unread,
Feb 13, 2017, 6:30:44 PM2/13/17
to scala-i...@googlegroups.com
Thank you for taking a look at this.  The gzipped file is attached.

To unsubscribe from this group and all its topics, send an email to scala-ide-user+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/937aedeb-e3fb-4d90-8b82-36de3062f21d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
SparkScalaIDE_project.tar.gz
Reply all
Reply to author
Forward
0 new messages