This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Embedding scala compiler

1 reply
Jesse Eichar
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.

Hi

I am trying to embed the scala compiler into my own program so that I
can compile classes on the fly and load them. I have used the
ant.scalac as my template for doing this. But when I run I get an
exception I have listed it below. I am using scala
2.8.0.r18014-b20090610020202. Any ideas why I am getting this error.
Do I need to put the scala-compiler jar on the boot classpath?

Thanks Jesse

scala.tools.nsc.MissingRequirementError: object scala not found.
at scala.tools.nsc.symtab.Definitions$definitions$.getModuleOrClass(Definitions.scala:409)
at scala.tools.nsc.symtab.Definitions$definitions$.getModule(Definitions.scala:354)
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackage(Definitions.scala:37)
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackageClass(Definitions.scala:38)
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:720)
at scala.tools.nsc.Global$Run.(Global.scala:646)
at net.pragmaticdesign.mss.ProjectCompiler$.compile(ProjectCompiler.scala:21)
(and so on, the rest is my code)

Gordon Tyler
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Embedding scala compiler

Jesse Eichar wrote:
> I am trying to embed the scala compiler into my own program so that I
> can compile classes on the fly and load them. I have used the
> ant.scalac as my template for doing this. But when I run I get an
> exception I have listed it below. I am using scala
> 2.8.0.r18014-b20090610020202. Any ideas why I am getting this error.
> Do I need to put the scala-compiler jar on the boot classpath?
>
> Thanks Jesse
>
> scala.tools.nsc.MissingRequirementError: object scala not found.

I think this means that you have to put the scala-library.jar in your
classpath. scala-compiler.jar's manifest doesn't declare a classpath to
reference scala-library.jar.

Ciao,
Gordon

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland