UnsupportedClassVersionError on play with JDK 1.7 - scala

I am getting the same error as this post. i'm trying to resolve the problem as mentioned in the proposed solution but i didn't understand how ?

If you are using version 2.4.x (or newer), you must use Java 8. From the Highlights of version 2.4:
Play 2.4 now requires JDK 8. Due to this, Play can, out of the box, provide support for Java 8 data types. For example, Play’s JSON APIs now support Java 8 temporal types including Instance, LocalDateTime and LocalDate.
To confirm that you are using Play 2.4, see file project/plugins.sbt.
Edit:
If you can't (or don't want to) use Java 8, you have to use Play 2.3 instead. To do so, you must edit project/plugins.sbt to change the used version of Play:
// Notice we are now using version 2.3.10
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.10")
If this is a brand new project, you can recreate it using 2.3 template instead:
activator new play-scala-2.3 name-of-your-project
Or, for Java:
activator new play-java-2.3 name-of-your-project

Related

scala binary vs scala full version convention

I am readying the following sbt page:
https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross-building
But i find the documentation not that great, and would like to clarify something which i think i understand but is not made explicit in the doc.
What is the convention for :
CrossVersion.binary (_<scala-binary-version>)
CrossVersion.full (_<scala-version>)
In other words i want a simple example of
_<scala-binary-version>
and of
_
is it :
Binary Version example 2.12
Scala version example 2.12.12
Is that the difference between a binary version and the scala version, where the later would include the compiler access and what not ?
EDIT1
The following example is given in the page:
These are equivalent:
"a" %% "b" % "1.0"
("a" % "b" % "1.0").cross(CrossVersion.binary)
This overrides the defaults to always use the full Scala version instead of the binary Scala version:
("a" % "b" % "1.0").cross(CrossVersion.full)
I only understand what is meant is the second statement, because i have been using the first and know what it does. But it is a guess, and i am just looking for an explicit confirmation with an example, which i believe could benefit any new scala dev in their journey.
So 2.12.12 is a full version (as well as a patch version) and 2.12 is a binary version.
Binary versions are useful because libraries compiled using a different but binary compatible version can be used in your project without any problems. For example, if you are using Scala 2.13.3 you can use a library that was compiled using 2.13.0 or 2.13.4 but not one compiled using 2.12.12.
The full version is useful for things that access the underlying compiler API which doesn't retain binary compatibility, for example, compiler plugins like the kind projector.
BTW, just for fun, 2.13.0-RC1 is another full version but not a patch version.

How to create a Play project with a specific version?

How can I create a new play project for a specific version?
using sbt new playframework/play-scala-seed.g8 it will always create a project pointing to the last version of Play (in this case 2.7).
The thing is that there isn't support for that version in gradle yet and I don't want to use sbt.
How can I specify version 2.6.6?
In your /project/plugins.sbt file you can specify which version of play you want to use.
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.6")
Reference : https://www.playframework.com/documentation/2.6.x/BuildOverview#Play-plugin-for-sbt-(/project/plugins.sbt)

Using util.parsing in Scala 2.11

I have written a Scala program with Eclipse Scala IDE that uses scala.util.parsing.JSON and I would like to transform it to support Scala 2.11 version. In Scala 2.11 I get an error:
error: object parsing is not a member of package util.
I have found out that the parsing library is not anymore in the util package by default, but has to be downloaded separately here.
I have downloaded that and tried to add it to my Eclipse project as a new source folder, but that didn't work out. The instructions are only for adding it to sbt, but I don't think that is relevant to me if I want to just use it in Eclipse.
Should I try to find a JAR file somewhere?
Should I try to find a JAR file somewhere?
Yes, you should. :)
And specifically, you should use this one (in SBT syntax):
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.2"
The above line should be all you need to add to build.sbt if you're using SBT. If you want to manually add it to your project by downloading it, you can find it on Maven Central.
The scala-parser-combinators library was removed in 2.11 so that people who don't use it don't have to pay a price for having it in the scala runtime library. Consequently, people who do want to use it have to now explicitly include it in their build. Note that the XML library was similarly removed in 2.11 to its own library.

Migrate from Play 2.0.4 to 2.1: Tika doesn't find my class anymore

I migrated a web application from Play Framework 2.0.4 to 2.1.
The application uses Apache Tika (V. 1.3) with a custom parser as described here on the Tika-Homepage.
A file myPlayProject/conf/META-INF/services/org.apache.tika.parser.Parsercontains the name of the custom parser class like this:
# Add here all custom parsers for Apache Tika.
com.test.CustomTikaParser
The custom parser will get detected with Play 2.0.4, but not anymore with Play 2.1. I have tried it with two fresh 2.0.4vs2.1-projects and got the same problem with V. 2.1.
Has something changed with the classpath between these Play versions?
(I can read the file META-INF/services/org.apache.tika.parser.Parser with Play 2.0.4 and Play 2.1 under the classpath.)
maybe try a simple command :
play clean-all update reload compile,
it will be clean your .target do an update and reload of your application then a compile...

Library 'scala-2.10.0-RC1 not used' thrown by IntelliJ integrating a Play 2 app

I've just generated a fresh Play! application, version 2.1-RC1.
This one includes two Scala compiler/library couple:
Scala 2.9.2
Scala 2.10.0-RC1
The whole well compiles within IntelliJ IDEA 12 but a warning occurs as the image shows it:
It would seem so that another compiler is used instead 2.10.0-RC1.
However, my Scala facet is configured as this:
What might be the warning cause?
I precise that I've got also a Scala variable environment (used for shell Scala commands) configured to point to scala-2.10.0-RC2, but I well imagine that IntelliJ is based on library that user indicates in Scala Facet.
You can remove that .jar from the libraries, it's not used because it's redundantly generated by IntelliJ SBT plubin.