2

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 )

PacificNW_Lover
  • 4,746
  • 31
  • 90
  • 144
  • tried cleaning project? – dlock Mar 04 '13 at 05:18
  • possible duplicate of [How to make Eclipse see the changes in Play! compiled templates?](http://stackoverflow.com/questions/10042987/how-to-make-eclipse-see-the-changes-in-play-compiled-templates) – ndeverge Mar 04 '13 at 08:07
  • 2
    "play clean compile" in the Play! console; then try a refresh of the project in Eclipse. – nico.ruti Mar 04 '13 at 13:04

4 Answers4

1

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!

Techmag
  • 1,383
  • 13
  • 24
1

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.

rfornal
  • 5,072
  • 5
  • 30
  • 42
0

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.

Alban Dericbourg
  • 1,616
  • 2
  • 16
  • 39
0

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.

John Kane
  • 4,383
  • 1
  • 24
  • 42