Skip to end of metadata
Go to start of metadata

See also the tutorial Getting Started with Scala.

Redirection Notice

Icon

1. Create play application with project wizard

Before you create a project make sure that Scala and Play Framework version 2.0 plugins are enabled in IntelliJ IDEA.

Icon

Starting with IntelliJ IDEA 14 EAP build, the Play 2.0 plugin is merged with the Scala plugin.

Open Project Wizard, select Play 2.x in Scala section and click Next.

On the next page of the wizard, specify your project's information and click Finish.

The IDE will create an empty application.

2. Import play project

IntelliJ IDEA lets you import an existing Play project.
Open Project Wizard and select Import Project.
You can also use main menu and select File→ Import Project.

In the window that opens, select a file that you want to import and click OK.

On the first page of the wizard, select Import project from external model option, choose SBT project from the list and click Next.



On the next page of the wizard, you can select the following options:

  • Use auto-import -select this check box to resolve all the changes made to the project automatically every time you refresh your project.
  • Create directories for empty content roots automatically - select this option to add a src directory to your project. When you import a project the scr directory is not created. When you create a project, the src directory is generated automatically.


Click Finish.

3. Check project settings

To make sure that project libraries are set up correctly, open FileProject Structure and check if module dependencies are resolved without warnings.

Since we use Scala for our application, also ensure that Compiler library is set in Scala facet settings.

4. Use code assistance features

When everything is set up, you can use code completion, navigation and on-the-fly code analysis features in your Play files. IntelliJ IDEA also supports code assistance for routes files and code inspections.

5. Run play app

You can run Play application and check the output in your default browser.

6. Debug play application

You can easily start a debugger session. You can use default configurations' settings and simply click OK.

See also the tutorial Getting Started with Scala.

  • No labels

37 Comments

  1. Anonymous

    Don't know what version of IDEA you are using for your illustrations but I'm using version 13.1.4, build #IU-135.1230, built on July 21, 2014, and the New Project dialog does NOT have a selection for project SDK.

    Thank you

    Gary

  2. Anonymous

    I am using the same version and there is no selection for Project SDK and also once you create the application, the project folder is not marked with [Play2App build]. 

    1. Absence of JDK selection is a bug, it will be fixed in the next nightly (i.e. tomorrow). As for mark, does the project dir have SBT icon? 

      1. Anonymous

        Nope, the project folder was no marked with n SBT icon. This is what I had to do. I first created a Play 2.x application. I then deleted the .idea and .iml files/directories. The I imported the project using an SBT model and it marked project with an SBT icon and then I was able to Run the Application as a Play 2.x app.

        Another thing I noticed is that I can only create Scala based applications i.e. my Application class/object is always Application.scala. How can I get a Java based Play application i.e. Application.java?

        1. Anonymous

          Thank you for your comment, I had the same issue! 

          Creating a new Play 2.0 project is buggy, it doesn't set anything correctly. You have to import the project as an SBT project. 

  3. Anonymous

    "Play 2.x" doesn't appear as depicted in step (1). I checked that both Scala and Play 2 Support were enabled. I tried this on both Mac and Linux Mint without success.

  4. Hi there,

    What version of IntelliJ IDEA are you using?

  5. Anonymous

    After manually installing the latest Play plugin (0.41.2) from http://plugins.jetbrains.com/plugin/7080?pr= (copied it manually under plugins folder) it worked as described above.

    1. Just to be clear: had to do this explicitly because the plugin installed by Intellij at this time did indeed lack the option described above. Maybe this will go away naturally when the plugin repo is resync-ed or something.

  6. Anonymous

    Has the Play 2.0 Framework plug in been integrated into the Scala plugin? 

    I'm running OSX and Intellij 13.1 and the Play 2.0 Framework is now available under Browse Repositories. Installing manually results in the plug in being marked red.

    Using just the latest Scala plug in I do not get the Play 2.x option when creating new projects. Importing existing play projects doesn't pick up that it is a play project. 

      1. Anonymous

        So why it's not working?

  7. Anonymous

    I am using Intellij 13.1.5 build 135.1289, with java8 and scala 2.11.

    the play 2.0 plugin is marked as erroneous (red) and I can't figure out why.

    any ideas?

    Thanks,

    Alon Segal

    1. Hello, 

      What plugin versions do you have? Red mark usually means that plugin versions are incompatible.

      Best Regards,

      Dmitry Naydanov

  8. Anonymous

    Latest (139.1) build of EAP and latest (1.0.182.5.EAP) Scala plugin - can't see Play2 project, only SBT and non-SBT. Seems the merger didn't went very well?

    1. Hello,

      do you use IDEA Ultimate? Also can you see Play2 project for java in corresponding section (among other frameworks)? 

      Best Regards, 

      Dmitry Naydanov

  9. Anonymous

    Hi,
    I'm using IDEA 13.1.5 community edition, build 135.1289, scala plugin 0.41.2
    cannot see any "play 2" project, either cannot see it in the run/debug configuration as "Play 2 app"

  10. Anonymous

    Hi,

    I am trying to import an existing play 2.4.0 project into IDEA 14.0 on OSX. I installed the Scala plugin before import, but there seems to be a problem after the import, since the project is not built correctly. In project structure, there are no modules, no libraries built, and also there seems to be no autocomplete or any play/scala support whatsoever.. 

    What could be the problem?

    1. Anonymous

      I have the same exact issue here.  IntelliJ IDEA v14 community edition + Scala plugin v1.0 doesn't show the Play 2.x option and doesn't import projects correctly.  I hope someone can fix it soon. Thanks.

      1. Anonymous

        deSame on Windows 8.1 x64

    2. Anonymous

      I have the same problem on OS X 10.10.

      1. Anonymous

        I reported it here: https://youtrack.jetbrains.com/issue/SCL-7835

        I hope more developers voice up and get it prioritized to get fixed.

  11. Anonymous

    Same issue on OS X 10.9.5. IntelliJ IDEA v14 community edition + Scala plugin v1.1 doesn't show the Play 2.x option and doesn't import projects correctly.

  12. I just installed IDEA14.0.2, build #IU-139.659, built on 12/6/2014.  As someone had posted on 8/18/2014:

    "......Another thing I noticed is that I can only create Scala based applications i.e. my Application class/object is always Application.scala. How can I get a Java based Play application i.e. Application.java?...."

    As of the IDEA build that I now have I see that this situation still exists.  Is there some other way of creating a Java based Play application that has yet to be documented in this confluence?  Is this still a bug?  Should we no longer expect to see a Java Based Play application being created using the wizard?  Can someone please let us know what the status of this is?

    Thank you

    Gary

    1. Anonymous

      Same question for me. How to start a Play2 project using Java ?

      1. Anonymous

        I'm in the same boat. I picked Play because it's the best Java framework I know, so I'd really like to learn how to use that method instead of Scala. While I intend to learn Scala at this point, I know Java right now, and have a need for Play right now, and Play excels in that arena.

  13. Anonymous

    I found in SO that Play Framework support is only available in Ultimate Edition. 

    https://www.jetbrains.com/idea/features/editions_comparison_matrix.html

    1. I have the Ultimate Edition.  I am a paying customer of IntellijIDEA.  Does anybody from IntellijIDEA care to respond to this paying customer concerning this issue?

      1. Hi there,

        If the Scala plugin is enabled in IntelliJ IDEA, you can select New Project -> Java and in the right part of the page, from the "Additional Libraries and Frameworks" list, select Play 2.x  to create Java project with Play 2.x framework. 

        1. Elena Kozlova:

          Thank you.  That is what I needed to know.  This one line of instruction from you is all it took for us to now know how to create a Play 2 application with Java.   I wonder why it took sooo long to get this answer, and I further wonder why such information is not mentioned on this confluence web page.

          Happy holidays to all.

          1. Sorry, for the delay. We currently are in the process of moving all the tutorials and their updates to our Web help (https://www.jetbrains.com/idea/help/intellij-idea.html). The correct info should be available shortly.) 

  14. Anonymous

    i have enable the Play 2.x in IDE,and the local play2 Env. has been set up successfully,while i am trying to create a Play2.x project ,i's failed,and meet the following error,any idea for this issue ?thanks 

    java.net.URISyntaxException: Illegal character in authority at index 7: file://${activator.home}/repository

    at java.net.URI$Parser.fail(URI.java:2829)

    at java.net.URI$Parser.parseAuthority(URI.java:3167)

    at java.net.URI$Parser.parseHierarchical(URI.java:3078)

    at java.net.URI$Parser.parse(URI.java:3034)

    at java.net.URI.<init>(URI.java:595)

    at java.net.URL.toURI(URL.java:938)

    at sbt.Resolver$url$.apply(Resolver.scala:253)

    at sbt.Classpaths$.sbt$Classpaths$$bootRepository(Defaults.scala:1549)

    at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1524)

    at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1524)

    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)

    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)

    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)

    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)

    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)

    at scala.collection.AbstractTraversable.map(Traversable.scala:105)

    at sbt.Classpaths$.appRepositories(Defaults.scala:1524)

    at sbt.Classpaths$$anonfun$40.apply(Defaults.scala:1040)

    at sbt.Classpaths$$anonfun$40.apply(Defaults.scala:1040)

    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

    at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:177)

    at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)

    at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:67)

    at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:76)

    at sbt.EvaluateSettings$$anon$3.run(INode.scala:72)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:745)

    [error] java.net.URISyntaxException: Illegal character in authority at index 7: file://${activator.home}/repository

    [error] Use 'last' for the full log.

    java.net.URISyntaxException: Illegal character in authority at index 7: file://$

    Unknown macro: {activator.home}

    /repository at java.net.URI$Parser.fail(URI.java:2829) at java.net.URI$Parser.parseAuthority(URI.java:3167) at java.net.URI$Parser.parseHierarchical(URI.java:3078) at java.net.URI$Parser.parse(URI.java:3034) at java.net.URI.<init>(URI.java:595) at java.net.URL.toURI(URL.java:938) at sbt.Resolver$url$.apply(Resolver.scala:253) at sbt.Classpaths$.sbt$Classpaths$$bootRepository(Defaults.scala:1549) at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1524) at sbt.Classpaths$$anonfun$appRepositories$1.apply(Defaults.scala:1524) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34) at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) at scala.collection.AbstractTraversable.map(Traversable.scala:105) at sbt.Classpaths$.appRepositories(Defaults.scala:1524) at sbt.Classpaths$$anonfun$40.apply(Defaults.scala:1040) at sbt.Classpaths$$anonfun$40.apply(Defaults.scala:1040) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:177) at sbt.EvaluateSettings$INode.evaluate(INode.scala:135) at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:67) at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:76) at sbt.EvaluateSettings$$anon$3.run(INode.scala:72) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
    [error] java.net.URISyntaxException: Illegal character in authority at index 7: file://$

    /repository
    [error] Use 'last' for the full log.

    1. Anonymous

      Ran into this issue recently, deleting the ~/.sbt/repository file fixes this. http://stackoverflow.com/a/28745077

      Hope this helps.

  15. Anonymous

    Before you create a project make sure that Scala and Play Framework version 2.0 plugins are enabled in IntelliJ IDEA. 

    (warning)

    Starting with IntelliJ IDEA 14 EAP build, the Play 2.0 plugin is merged with the Scala plugin.

    Cannot understand.. does this mean that this page, with its screenshots, is obsolete?

    1. Hi there, 

      It means that you need only Scala plugin to be able to create/import Play 2.x project.

      https://www.jetbrains.com/idea/help/getting-started-with-play-2-x.html

  16. Anonymous

    How do i choose the right application in the starter if i have several play apps in my project (eg. web-service and admin-ui)?

  17. Anonymous

    I do not see a Run option as you have in your right-click. Please see this image: i.imgur.com/Dxb4u2c.png .

    You have an image with the Run option as follows. Did I miss something?

Write a comment…