Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Scala code in Intellij Idea 10

I have simple problem. I installed idea and scala plugin. Create project and add wants to run simple println("Hello world!").

I create "scala script". Add this line. And when i run it, i have error expected class or object definition.

How can i can run it and see the output?

Thanks

like image 963
Falcon Avatar asked Oct 21 '11 18:10

Falcon


2 Answers

I have just installed idea + scala plugin and had the same error on running my 1st "hello, world".

I solved it with Run -> Edit Configurations... -> select the script run configuration -> untick "Make" under "Before launch"

like image 93
ililit Avatar answered Nov 12 '22 00:11

ililit


According to Getting Started with IntelliJ IDEA Scala Plugin:

You can also turn your Scala object into a script. Just remove all declarations from the file, leave the executable statement only - println("Hello, World!"), and run the script as described above.

However I confirm that it results with the same error as you quoted. I think this is a bug (or inaccurate documentaion), file a bug, Jetbrains guys are developing this plugin very actively.

like image 31
Tomasz Nurkiewicz Avatar answered Nov 12 '22 00:11

Tomasz Nurkiewicz