Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:33:21+00:00 2026-06-05T10:33:21+00:00

I have to use scala parser inside Play Framework application. import scala.tools.nsc._ trait Foo

  • 0

I have to use scala parser inside Play Framework application.

import scala.tools.nsc._

trait Foo
class Parser {
    def parse(code: String) = {
        val settings = new Settings
        settings.embeddedDefaults[Foo]
        val interpreter = new Interpreter(settings)
        interpreter.parse(code)
    }
}

I have following dependency in Build.scala

"org.scala-lang" % "scala-compiler" % "2.9.1"

This code works when build using SBT. In Play it ends with NullPointerException and:

Failed to initialize compiler: object scala not found.

** Note that as of 2.8 scala does not assume use of the java classpath.

** For the old behavior pass -usejavacp to scala, or if using a Settings

** object programatically, settings.usejavacp.value = true.

Build.scala

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "com.qwerty.utils"
    val appVersion      = "1.0-SNAPSHOT"
    val scalaVersion    = "2.9.1"

    val appDependencies = Seq(
        "org.scala-lang" % "scala-compiler" % "2.9.1"
    )
    
    val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
      // Add your own project settings here
    
    )

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:33:23+00:00Added an answer on June 5, 2026 at 10:33 am

    For background on embeddedDefaults, see the original proposal.

    The container (Play) must define the ‘app.class.path’ and ‘boot.class.path’ resources and then embeddedDefaults will use them to configure the interpreter properly for the environment. So, this is an enhancement for Play.

    If you can pass the necessary classpaths into your application, you can configure classpaths and classloaders explicitly yourself with something like:

    val settings = new Settings
    settings.classpath.value = "<classpath>"
    settings.bootclasspath.value =
      settings.bootclasspath.value + File.pathSeparator +
      "<extra-bootclasspath>"
    val interpreter = new Interpreter(settings) {
        override def parentClassLoader = classOf[Foo].getClassLoader
    }
    interpreter.parse(code)
    

    The bootclasspath should generally contain scala-library.jar and the classpath should contain the application jars.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Scala 2.9.1. I have a simple scala interpreter: import scala.tools.nsc.interpreter.IMain import scala.tools.nsc.interpreter.Results.Result
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but
Can I use scala List in Java, like : import scala.collection.immutable.List; class HelloScalaList {
I am testing a parser I have written in Scala using ScalaTest. The parser
In my application I have use some data ValueCell (something like 20) and I
I've grabbed some Scala CSV parsing code from here: Use Scala parser combinator to
I am thinking of writing a web app in Scala using the Play! framework
I have a Scala project and I use Scala-Eclipse-Plugin along with sbt. So far
I'd like to use a timer in a Scala Swing application. I can use
I have Scala 2.8.0 installed and don't wish to use Scala 2.7. Whenever I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.