3

I am getting an error at return :

public static Result home(String name)
{           
    return ok(home.render(name));
}

For which Eclipse says, home can't be resolved. I know it is more of Scala than Java, but is there any way I can get rid of such errors. Well, without disabling error messaging (I see lot of such answers here on SO). Also, is there anyway I can make my Eclipse work autocomplete for Scala ?

Ah, I just noticed one more problem there. To use an external jar, all I have too keep jars in a lib folder and run eclipse again from cli. It works fine in browser but a class making use of jars is all wrong, as per Eclipse.

akshayb
  • 1,219
  • 2
  • 18
  • 44
  • What is the error? Be more descriptive. Include any stack traces you can get while running the program (if the program runs correctly as expected, you can ignore or disable Eclipse error). – ADTC Jul 23 '13 at 10:02
  • 2
    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 Jul 23 '13 at 12:41
  • nico_ekito I don't think it is duplicate. Code is working fine in browser in my case, it just problem that Eclipse can't find method "render" automatically created somewhere by play. @ADTC, there is nothing more to tell than home can't be resolved, no stack trace as it works fine. – akshayb Jul 23 '13 at 14:57
  • Did you set your project build path correctly? Included the necessary libraries? – ADTC Jul 24 '13 at 01:19

4 Answers4

13

You have to do 2 things on Play 2.4:

  1. Run activator eclipse (from Activator UI or command line)
  2. Go to Java Build Path > Libraries > Add External Class Folder and point it to the output folder: target/scala-<version>/classes
Jay Q.
  • 4,979
  • 3
  • 33
  • 36
  • thank you, finally i found what i need to add in classpath for 2.x version of PF...everywhere i read i should have add classes_managed, but it's right for old versions. – pagurix Jul 14 '15 at 11:05
  • Upgrade `sbteclipse` to version `5.1.0` (which was released on January 12th 2017) - you wont need to add the folder to the class path by yourself anymore. – mkurz Jan 13 '17 at 11:29
5

Use eclipse command, build the project from eclipse and refresh the project.

Marco
  • 1,494
  • 13
  • 23
3

You could try Project > Properties > Java Build Path > Order and Export and select all less the jre. I solved my problem doing by this way.

1

I had to "activator eclipse" again after starting eclipse.

ozma
  • 1,633
  • 1
  • 20
  • 28