Old question: sbt - object is not a member of package

1,467 views
Skip to first unread message

Zhan Wang

unread,
Mar 10, 2015, 6:24:03 PM3/10/15
to scala...@googlegroups.com
Hi I'm new to scala and sbt. I wrote some test code and ran into some old question - object is not a member of package. I searched everywhere but got no luck. Below is my code:

########### build.sbt ############
name := "Test Codes"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % "1.2.0",
  "commons-io" % "commons-io" % "2.4",
  "com.google.code.gson" % "gson" % "2.2.4",
  "org.la4j" % "la4j" % "0.4.9"
)

javacOptions ++= Seq("-source", "1.7", "-target", "1.7")


############  scala code ##############

package app.mycompany

import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import app.mycompany.DataPrepSpark

object TrainModels {

  def runTraining(input: String, output: String) = {
    val conf = new SparkConf().setAppName("Naive Bayes with Spark")
    val sc = new SparkContext(conf)

    val rawData = sc.textFile(input)
    val groupedData = rawData groupBy { G =>
      G.split("\t")(0)
    }

    val models = groupedData map { G =>
      DataPrepSpark.processData(G._1, G._2.toArra, 5)
    }

    models.saveAsTextFile(output)
  }

  def main(args: Array[String]) = {
    runTraining(args(0), args(1))
  }
}

############## java code ###############

packageapp.mycompany;

import com.google.gson.*;
import org.apache.commons.io.FileUtils;
import org.la4j.io.MatrixMarketStream;
import org.la4j.matrix.Matrix;
import org.la4j.matrix.sparse.CCSMatrix;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test
{

    public static String processData(String id, String[] rows, int length)
    {   
        System.out.println("TESTING....................");
        System.out.println(length);
        return id;
    }
}



Scala and Java codes are in the same package but the java class just can't be found...

Thanks!

mar

unread,
Mar 12, 2015, 3:21:59 AM3/12/15
to scala...@googlegroups.com
Maybe it is because you've named your class Test but calls it like DataPrep Spark?
Reply all
Reply to author
Forward
0 new messages