poornerd

my thoughts on programming and other nerdy stuff

How to set the Java Version for Compiling a Play Framework Module

| 3 Comments

@jaliss and I were recently wondering how to make sure that a module was compiled with JSDK 1.6 after we had upgraded the Java Version on our Macbooks.

Stackoverflow user mgregori just provided this solution (Thanks!):

In the file project/Build.scala, add the setting below if you want to compile with java 1.6 :

val main = play.Project(appName, appVersion, appDependencies).settings(
  // Force compilation in java 1.6
  javacOptions in Compile ++= Seq("-source", "1.6", "-target", "1.6")
)
If you have read this far, you may as well follow me on Twitter:

Author: poornerd

Tech­nol­o­gist, Entre­pre­neur, Vision­ary, Pro­gram­mer :: Grad­u­ated from USC (Uni­ver­sity of South­ern Cal­i­for­nia) with a degree in Com­puter Sci­ence. After 10+ years of free­lance con­sult­ing and pro­gram­ming, he co-founded Site­Force AG eBusi­ness Solu­tions in 1999 in Munich (München), Ger­many.

3 Comments

  1. I don’t have a Build.scala file in my Play 2.3.1 / Java services. I tried to add what you have to a new file but it didn’t compile.

    Does this method work for Play 2.3? Is there a new way to specify Java version?

  2. In the file build.sbt add the following line

    javacOptions in Compile ++= Seq(“-source”, “1.6”, “-target”, “1.6”)

    Make sure to leave a blank line before and after the line.

  3. You post very interesting articles here. Your website
    deserves much more traffic. It can go viral if you give it initial boost,
    i know useful service that can help you, simply type in google:
    svetsern traffic tips

Leave a Reply

Required fields are marked *.