2

I recently updated to Eclipse Juno, which also updated my Scala to 2.10. I know that Actors are deprecated now, but I'd still like to use them. The scala-actors.jar and scala-actors-migration.jar are part of my Eclipse build path, however, I get "object actors is not a member of package scala" for the imports. Any tries to re-add the scala library to the project failed didn't fix it either.

Mac OS X Lion with Eclipse Juno and Scala 2.10.

Some code (Marked the errors XXX):

import scala.actors.Actor    XXX actors not found in scala
import scala.actors.Actor._  XXX actors not found in scala

  class Solver() extends Actor {   XXX Actor not found

    def act() {
      // Read file
      val source = io.Source.fromFile("src/labyrinth.txt", "utf-8")
      val lines = source.getLines.toList
      source.close()

      // Fill multidimensional array
      var labyrinth = Array.ofDim[Cell](lines.length, lines.apply(0).length)
      for (i <- 0 until lines.length) { // each line
        for (j <- 0 until lines.apply(0).length) { // each column
          labyrinth(i)(j) = new Cell(lines.apply(i).toList.apply(j)) // Fill array cell with character
        }
      }

      // Search for start
      for (k <- 0 until labyrinth(0).length) {
        if (labyrinth(0)(k).character.toString() == "?") {
          val start = new CheckCell(labyrinth, Array((1, k)), this).start // Kick off search
          while (true) {
            receive { XXX receive not found
              case FoundSolution =>  XXX FoundSolution not found
                Console.println("Pong: stop")
                start ! Stop  XXX Stop not found
                exit()
            }
          }
        }
      }

    }

  }
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
johnny
  • 8,696
  • 6
  • 25
  • 36
  • Do you have any directory called 'scala', part of your classpath or your source directory? It looks like the compiler is looking in the wrong scala package, which can arise from that. Make sure you don't define a 'scala' package yourself, that could shadow the *real* one! – Iulian Dragos Jan 27 '13 at 22:09

1 Answers1

1

Your example works fine for me (except the missing types, like Cell and CheckCell). I believe you might have one of the following:

  • a package scala.blah declaration in one of your source files
  • a source folder that contains scala as a sub-directory. Check that in Project Properties, Build Path and look for source folders. If you use the maven convention, src/main/scala should be a source directory (not just src/ or src/main/).

Both points above can shadow the standard scala package and replace it with your declaration (or directory), which obviously does not have an Actor type.

Iulian Dragos
  • 5,692
  • 23
  • 31