1
votes

Have installed the Scala plugin < http://download.scala-ide.org/nightly-scala-ide-juno-210x > in Eclipse Juno.

Am using the following versions:

play 2.1.0 java version "1.6.0_41" Scala code runner version 2.10.0 -- Copyright 2002-2012, LAMP/EPFL I am able to write Scala programs using Eclipse and also created a Java based Play project which I imported into Eclipse by running play eclipse.

Am able to see the sample code run correctly in Chrome but have weird errors regarding the play code.

e.g.

public class Application extends Controller {  

   public static Result index() {
       return ok(index.render("Your new application is ready."));
   } 
}

There's a red curly line underneath index which the Eclipse problem's view states:

"index cannot be resolved"

Attached is a screenshot giving examples of these type of problems...

Is there a way to have Eclipse recognize these errors?

Play Syntax Problems in Eclipse

( You can open this image in a new tab on your browser in order to see it in a larger resolution )

4
tried cleaning project?deadlock
"play clean compile" in the Play! console; then try a refresh of the project in Eclipse.nico.ruti

4 Answers

1
votes

I just had EXACTLY this problem with a clean, fresh install of Play (most recent version(s) of everything downloaded on Jan 17th 2015).

I thought to myself -- oh god here we go again -- a wonderful framework when it works but you have to invest 4 hours of mind numbing research just to get the first line of code to compile properly.

Turns out that running the ~compile command in the activator window and making a change in the Application.java and saving it did the trick. Changes to the file alone didn't do it nor did running update in activator either nor restarting or reloading eclipse.

Thank you for asking the question as this is what shows up when googling return ok(index.render("Your new application is ready.")); and it looks like I'll be productive now in short order instead of wasting time with the search gods...

I would also give the answerer (Alban) a star but I'm not allowed to yet sadly...

You would think that in 2 years a simple problem like this would have long been fixed long ago!

1
votes

rather than using;

activator eclipse

use;

activator "eclipse with-source=true"

it takes a little while but when it is completed, it doesn't display related error.

0
votes

You have to run compilation from Play! console.

To do it incrementally (ie every time you make a change in your source), you can run:

play ~compile

I also configured Eclipse to automatically refresh resources: Window > Preferences > General > Workspace > Refresh using native hooks or polling.

0
votes

Not sure if this is the issue but Play has a way to set up your project for various ide's. Try running eclipsify, though eclipse is known to keep dirty caches so that could be one of the issues. If this does not work maybe try running it with the: with-source=true option.