Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a Play Framework 2.1 project in IntelliJ?

I have an existing Play 2.1 project. I've been running it with the console and it works fine. However, when I try to run it with IntelliJ using these instructions it doesn't work:

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

First I tried just running it by right clicking on the app and selecting "run play 2 app". It would not run and it gave me this error:

sbt.IncompatiblePluginsException: Binary incompatibility in plugins detected.

After some research into the issue I added -Djline.terminal= to my JVM options and tried again. This time it ran, but gave this error when I tried to open a page in the browser:

Global : Unsupported major.minor version 52.0

Finally, I tried reimporting my project into intellij. Before it would import, it forced me to update my SBT version in build.properties from 0.12.2 to 0.12.4. I did this, but still getting the same errors listed above.

NOTE: I have Java 7 set as my JDK.

Here is the full stack trace:

play.api.PlayException: Cannot init the Global object[Global : Unsupported major.minor version 52.0]
    at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:57) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:51) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:50) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:383) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:383) ~[play_2.10-2.1.1.jar:2.1.1]
Caused by: java.lang.UnsupportedClassVersionError: Global : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_80]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[na:1.7.0_80]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.7.0_80]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[na:1.7.0_80]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[na:1.7.0_80]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.7.0_80]
like image 727
TomahawkPhant Avatar asked Jul 27 '17 22:07

TomahawkPhant


1 Answers

The issue is because of Java version mismatch. Referring to the Wikipedia Java Class Reference :

J2SE 8 = 52

J2SE 7 = 51

When importing project try to change project SDK from Java 8 to Java 7

You can try adding the following to your build.sbt:

javacOptions ++= Seq("-source", "1.7", "-target", "1.7")

like image 72
b6ed7 Avatar answered Sep 29 '22 21:09

b6ed7