2

I got seemingly simple problem.. and usually I could find a solution easily from stackoverflow, but I had no luck this time.

Here's problem. I have created a object in a package called com.kwoolytech.scalacommon.

package com.kwoolytech.scalacommon

object Syslog {

  def emergency(s: String) = { println("[Emergency] " + s) }
  def alert(s: String)     = { println("[Alert] "     + s) }
  def critical(s: String)  = { println("[Critical] "  + s) }
  def error(s: String)     = { println("[Error] "     + s) }
  def warning(s: String)   = { println("[Warning] "   + s) }
  def notice(s: String)    = { println("[Notice] "    + s) }
  def debug(s: String)     = { println("[Debug] "     + s) }
  def info(s: String)      = { println("[Info] "      + s) }

}

All I want is to use this object in another package I've created.

package com.kwoolytech.kwoolybot

import com.kwoolytech.scalacommon.Syslog

class Dice(command: List[String], callback: List[String] => Unit) extends Bot {

  override def run() = {
    command.head match {
      case "roll" => roll(command.tail, callback)
      case _ => Syslog.debug(getClass + " Invalid command.")
    }
  }

I got a compile erorr, object scalacommon is not a member of package com.kwoolytech

Both source files are located under a same project.

  • Syslog.scala : src/scalacommon/syslog/Syslog.scala
  • Dice.scala : src/main/dice/Dice.scala

Appreciate on your advice.

Vaibhav Bajaj
  • 1,934
  • 16
  • 29
Harry
  • 709
  • 1
  • 6
  • 16
  • See if this helps: http://stackoverflow.com/questions/21701452/scala-import-not-working-object-database-is-not-a-member-of-package-com-me-pro – insan-e Jul 17 '16 at 09:03
  • 1
    Seems like a project configuration issue. Are you using SBT, gradle, .. etc? Can you post the relevant build files? – JRomero Jul 17 '16 at 16:46
  • It seems as if Dice.scala is being compiled but not Syslog.scala. – pedrofurla Jul 17 '16 at 19:18
  • Looks like you placed Syslog.scala in a non standard directory. Standard prectice is to put all prod code in src/main/scala and test code in src/test/scala – Dragisa Krsmanovic Jul 18 '16 at 01:00

2 Answers2

0

Base on the comments, I found a reason! Thanks all. All of your comments were right.

I was using intelliJ and src/scalacommon folder wasn't configured as a source folder.

Hence in the IDE, File -> Project Structure... and set the folder as a source folder, solves the issue.

Harry
  • 709
  • 1
  • 6
  • 16
0

I have same issue with you, but i solve it with bulid the project ! https://ci.apache.org/projects/flink/flink-docs-stable/flinkDev/building.html

after maven bulid the project sucessful, I can run the example.

Hope my answer can help you

r pp
  • 1