Created singleton object can't be detected in main function (Scala)









up vote
0
down vote

favorite












Singleton object LongLines which I created can't be recognized in object with main function (FindingLines). I put their files (LongLines.scala, FindingLines.scala ) in /src/main/scala/com/files/lines directory. Program code should have to find in particular file the lines which length is greater than parameter width.



Codes:



1) LongLines.scala (version from book I learn):



package com.files.lines
import scala.io.Source

object LongLines

def processFile(filename: String, width: Int)
val source = Source.fromFile(filename)
for (line <- source.getLines())
processLine(filename, width, line)


private def processLine(filename: String,
width: Int, line: String)
if (line.length > width)
println(filename +": "+ line.trim)




2) LongLines.scala (my own version):



package com.files.lines
import scala.io.Source._
import java.nio.files.Paths._

object LongLines

def processFile(filePath: String, width:Int): Unit =
val path = get(filePath)
val fileName = path.getFileName.toString
val lines = fromFile(filePath).getLines().toList
for (line<-lines) processLines(fileName,line,width)


private def processLines(fileName: String, line: String, width: Int): Unit =
if (line.length() > width) println(s"$fileName: $line");




3) FindingLines.scala (book version I used - only version):



package com.files.lines 

object FindLongLines

def main(args: Array[String]) =
val width = args(0).toInt
for (arg <- args.drop(1))
LongLines.processFile(arg, width)






Error (compiled from linux terminal):



After I compiled program with my version and book version of LongLines.scala (separately, of course):



 scalac FindingLines.scala 


I've got this error:



FindLongLines.scala:15: error: not found: value LongLines
LongLines.processFile(arg, width)
^
one error found









share|improve this question



























    up vote
    0
    down vote

    favorite












    Singleton object LongLines which I created can't be recognized in object with main function (FindingLines). I put their files (LongLines.scala, FindingLines.scala ) in /src/main/scala/com/files/lines directory. Program code should have to find in particular file the lines which length is greater than parameter width.



    Codes:



    1) LongLines.scala (version from book I learn):



    package com.files.lines
    import scala.io.Source

    object LongLines

    def processFile(filename: String, width: Int)
    val source = Source.fromFile(filename)
    for (line <- source.getLines())
    processLine(filename, width, line)


    private def processLine(filename: String,
    width: Int, line: String)
    if (line.length > width)
    println(filename +": "+ line.trim)




    2) LongLines.scala (my own version):



    package com.files.lines
    import scala.io.Source._
    import java.nio.files.Paths._

    object LongLines

    def processFile(filePath: String, width:Int): Unit =
    val path = get(filePath)
    val fileName = path.getFileName.toString
    val lines = fromFile(filePath).getLines().toList
    for (line<-lines) processLines(fileName,line,width)


    private def processLines(fileName: String, line: String, width: Int): Unit =
    if (line.length() > width) println(s"$fileName: $line");




    3) FindingLines.scala (book version I used - only version):



    package com.files.lines 

    object FindLongLines

    def main(args: Array[String]) =
    val width = args(0).toInt
    for (arg <- args.drop(1))
    LongLines.processFile(arg, width)






    Error (compiled from linux terminal):



    After I compiled program with my version and book version of LongLines.scala (separately, of course):



     scalac FindingLines.scala 


    I've got this error:



    FindLongLines.scala:15: error: not found: value LongLines
    LongLines.processFile(arg, width)
    ^
    one error found









    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Singleton object LongLines which I created can't be recognized in object with main function (FindingLines). I put their files (LongLines.scala, FindingLines.scala ) in /src/main/scala/com/files/lines directory. Program code should have to find in particular file the lines which length is greater than parameter width.



      Codes:



      1) LongLines.scala (version from book I learn):



      package com.files.lines
      import scala.io.Source

      object LongLines

      def processFile(filename: String, width: Int)
      val source = Source.fromFile(filename)
      for (line <- source.getLines())
      processLine(filename, width, line)


      private def processLine(filename: String,
      width: Int, line: String)
      if (line.length > width)
      println(filename +": "+ line.trim)




      2) LongLines.scala (my own version):



      package com.files.lines
      import scala.io.Source._
      import java.nio.files.Paths._

      object LongLines

      def processFile(filePath: String, width:Int): Unit =
      val path = get(filePath)
      val fileName = path.getFileName.toString
      val lines = fromFile(filePath).getLines().toList
      for (line<-lines) processLines(fileName,line,width)


      private def processLines(fileName: String, line: String, width: Int): Unit =
      if (line.length() > width) println(s"$fileName: $line");




      3) FindingLines.scala (book version I used - only version):



      package com.files.lines 

      object FindLongLines

      def main(args: Array[String]) =
      val width = args(0).toInt
      for (arg <- args.drop(1))
      LongLines.processFile(arg, width)






      Error (compiled from linux terminal):



      After I compiled program with my version and book version of LongLines.scala (separately, of course):



       scalac FindingLines.scala 


      I've got this error:



      FindLongLines.scala:15: error: not found: value LongLines
      LongLines.processFile(arg, width)
      ^
      one error found









      share|improve this question















      Singleton object LongLines which I created can't be recognized in object with main function (FindingLines). I put their files (LongLines.scala, FindingLines.scala ) in /src/main/scala/com/files/lines directory. Program code should have to find in particular file the lines which length is greater than parameter width.



      Codes:



      1) LongLines.scala (version from book I learn):



      package com.files.lines
      import scala.io.Source

      object LongLines

      def processFile(filename: String, width: Int)
      val source = Source.fromFile(filename)
      for (line <- source.getLines())
      processLine(filename, width, line)


      private def processLine(filename: String,
      width: Int, line: String)
      if (line.length > width)
      println(filename +": "+ line.trim)




      2) LongLines.scala (my own version):



      package com.files.lines
      import scala.io.Source._
      import java.nio.files.Paths._

      object LongLines

      def processFile(filePath: String, width:Int): Unit =
      val path = get(filePath)
      val fileName = path.getFileName.toString
      val lines = fromFile(filePath).getLines().toList
      for (line<-lines) processLines(fileName,line,width)


      private def processLines(fileName: String, line: String, width: Int): Unit =
      if (line.length() > width) println(s"$fileName: $line");




      3) FindingLines.scala (book version I used - only version):



      package com.files.lines 

      object FindLongLines

      def main(args: Array[String]) =
      val width = args(0).toInt
      for (arg <- args.drop(1))
      LongLines.processFile(arg, width)






      Error (compiled from linux terminal):



      After I compiled program with my version and book version of LongLines.scala (separately, of course):



       scalac FindingLines.scala 


      I've got this error:



      FindLongLines.scala:15: error: not found: value LongLines
      LongLines.processFile(arg, width)
      ^
      one error found






      package singleton main






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 1:36

























      asked Nov 9 at 3:10









      Marko Gavranovic

      112




      112






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Solution:



          1) I removed "package com.file.lines" from both files (FindingLines.scala, LongLines.scala) - that means I need not to remove those files in this package (directory). Those two files could stay in src/main/scala directory.
          2) scalac FindingLines.scala LongLines.scala
          3) scala FindingLines.scala 45 ~/workspace/Rational/src/Rational.scala





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219314%2fcreated-singleton-object-cant-be-detected-in-main-function-scala%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Solution:



            1) I removed "package com.file.lines" from both files (FindingLines.scala, LongLines.scala) - that means I need not to remove those files in this package (directory). Those two files could stay in src/main/scala directory.
            2) scalac FindingLines.scala LongLines.scala
            3) scala FindingLines.scala 45 ~/workspace/Rational/src/Rational.scala





            share|improve this answer


























              up vote
              0
              down vote













              Solution:



              1) I removed "package com.file.lines" from both files (FindingLines.scala, LongLines.scala) - that means I need not to remove those files in this package (directory). Those two files could stay in src/main/scala directory.
              2) scalac FindingLines.scala LongLines.scala
              3) scala FindingLines.scala 45 ~/workspace/Rational/src/Rational.scala





              share|improve this answer
























                up vote
                0
                down vote










                up vote
                0
                down vote









                Solution:



                1) I removed "package com.file.lines" from both files (FindingLines.scala, LongLines.scala) - that means I need not to remove those files in this package (directory). Those two files could stay in src/main/scala directory.
                2) scalac FindingLines.scala LongLines.scala
                3) scala FindingLines.scala 45 ~/workspace/Rational/src/Rational.scala





                share|improve this answer














                Solution:



                1) I removed "package com.file.lines" from both files (FindingLines.scala, LongLines.scala) - that means I need not to remove those files in this package (directory). Those two files could stay in src/main/scala directory.
                2) scalac FindingLines.scala LongLines.scala
                3) scala FindingLines.scala 45 ~/workspace/Rational/src/Rational.scala






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 11 at 1:40

























                answered Nov 11 at 1:19









                Marko Gavranovic

                112




                112



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219314%2fcreated-singleton-object-cant-be-detected-in-main-function-scala%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    政党