title: Scala "constructor Stopwatch cannot be accessed in class Main"
body: <p>Summary on resolution, I thought I was dealing with a Scala problem but it turns out Stopwatch and Scala Logging have private constructors, and I was not calling the proper public methods to instantiate them. gzm0's answer below points this out.</p>
  
  <hr>
  
  <p>Trying to use Guava Stopwatch and Scala Logging, no matter whether I create a <code>new Stopwatch()</code> or <code>new Logger()</code> in Main or in an instantiated class I get this error with <code>gradle run</code>:</p>
  
  <pre><code>constructor Logger in class Logger cannot be accessed in class RedBlackTree4150
  var loggerInst = new Logger()
  constructor Stopwatch in class Stopwatch cannot be accessed in class RedBlackTree4150
  var stopWatchInst = new Stopwatch()
  </code></pre>
  
  <p>If this is a duplicate of <a href="https://stackoverflow.com/questions/15860647/scala-method-clone-in-class-object-cannot-be-accessed-in-t-access-to-protected-m">this</a> or <a href="https://stackoverflow.com/questions/34108613/why-does-scala-compiler-fail-with-object-sparkconf-in-package-spark-cannot-be-a">this</a> question I don't know enough to realize it. I looked at <a href="https://stackoverflow.com/questions/20030826/scala-case-class-private-constructor-but-public-apply-method">this question</a> but it doesn't have an accepted answer, and I tried (just for fun) to take my parens off my constructor calls to no avail.</p>
  
  <p><em>Writing my first Gradle/Scala project for a Analysis of Algorithms assignment.</em> I think if I was in Java I would be asking about static vs. non-static, not sure if that's the type of issue I am dealing with. Scala is not part of the assignment so I am not using a homework tag.</p>
  
  <p>Here's how I am calling them and the first part of my program, <a href="https://github.com/jimlohse/RedBlackTree4150" rel="nofollow noreferrer">the full .scala file and the build.gradle are on Github</a></p>
  
  <pre><code>import com.google.common.base.Stopwatch
  import com.typesafe.scalalogging.slf4j.Logger
  import scala.collection.immutable.TreeMap
  import java.util.concurrent.TimeUnit
  
  object Main extends App {
    // var rbtree = new RedBlackTree4150(logger, stopWatch)
    var rbtree = new RedBlackTree4150()
  }
  // class RedBlackTree4150 (var loggerInst: Logger, var stopWatchInst: Stopwatch) {
  class RedBlackTree4150() {
    var loggerInst = new Logger()
    var stopWatchInst = new Stopwatch()
  </code></pre>
  
  <p>As you can see I have tried simplifying this by making it all one Object, and by instantiating Logger and Stopwatch in Main and passing them to the class (bad idea I know) but none of that works. What simple Scala thing am I missing here? Thanks.</p>
  
  <hr>
  
  <p>Otherwise I believe I have all my dependencies in the project properly, and I get the same error on command line. </p>
  
  <p>I do have one more error <a href="https://stackoverflow.com/questions/34984070/scala-error-value-map-is-not-a-member-of-double/">I posted as a separate question here,</a> just in case it's relevant, the error is:</p>
  
  <pre><code>/home/jim/workspace/Scala/RedBlackTree4150/src/main/scala/Main.scala:36: value map is not a member of Double
    timingsMap = for (i &lt;- powersList; j &lt;- runTest(i)) yield i -&gt; j
  </code></pre>