title: eclipse - testng the method is undefined for the type Utils
body: <p>I am copying pasting code from <a href="https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/reporters/TestHTMLReporter.java" rel="nofollow noreferrer">here</a>, the whole file, and then I would like to make changes to it and implement <code>IReporter</code> and I have done all necessary imports in my java file.
  All the errors were gone except one  related to below import:</p>
  
  <p><code>import org.testng.internal.Utils;</code></p>
  
  <p>The error is </p>
  
  <pre><code>The method longStackTrace(Throwable, boolean) is undefined for the type Utils   
  
  The method shortStackTrace(Throwable, boolean) is undefined for the type Utils
  </code></pre>
  
  <p>These two are defined , I can see it <a href="http://static.javadoc.io/org.testng/testng/6.11/org/testng/internal/Utils.html" rel="nofollow noreferrer">here</a> and <a href="https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/internal/Utils.java" rel="nofollow noreferrer">here</a> . I tried to clean the project , restart eclipse but nothing worked. 
  in <code>pom.xml</code></p>
  
  <pre><code>&lt;testng.version&gt;6.10&lt;/testng.version&gt;
   &lt;dependency&gt;
               &lt;groupId&gt;org.testng&lt;/groupId&gt;
               &lt;artifactId&gt;testng&lt;/artifactId&gt;
               &lt;version&gt;${testng.version}&lt;/version&gt;
               &lt;scope&gt;test&lt;/scope&gt;
               &lt;scope&gt;compile&lt;/scope&gt; //tried this also
    &lt;/dependency&gt;
  </code></pre>
  
  <p>below is the class</p>
  
  <pre><code>package firsttestngpackage;
  
  import java.util.Map;
  
  //import org.apache.xml.serializer.utils.Utils;
  
  import org.testng.IReporter;
  import org.testng.ISuite;
  import org.testng.ISuiteResult;
  import org.testng.reporters.TestHTMLReporter;
  import org.testng.xml.XmlSuite;
  
  import org.testng.ITestContext;
  import org.testng.ITestNGMethod;
  import org.testng.ITestResult;
  import org.testng.Reporter;
  import org.testng.TestListenerAdapter;
  import org.testng.TestRunner;
  import org.testng.internal.Utils;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.io.Serializable;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.Date;
  import java.util.List;
  import java.util.Objects;
  
  
  
  public class CustomReport  implements IReporter {
  
       @Override
          public void generateReport(List&lt;XmlSuite&gt; xmlSuites, List&lt;ISuite&gt; suites,
                                     String outputDirectory) {
  
          }
  
       public static void generateTable(PrintWriter pw, String title,
                Collection&lt;ITestResult&gt; tests, String cssClass, Comparator&lt;ITestResult&gt; comparator)
            {
              pw.append("&lt;table width='100%' border='1' class='invocation-").append(cssClass).append("'&gt;\n")
                .append("&lt;tr&gt;&lt;td colspan='4' align='center'&gt;&lt;b&gt;").append(title).append("&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;\n")
                .append("&lt;tr&gt;")
                .append("&lt;td&gt;&lt;b&gt;Test method&lt;/b&gt;&lt;/td&gt;\n")
                .append("&lt;td width=\"30%\"&gt;&lt;b&gt;Exception&lt;/b&gt;&lt;/td&gt;\n")
                .append("&lt;td width=\"10%\"&gt;&lt;b&gt;Time (seconds)&lt;/b&gt;&lt;/td&gt;\n")
                .append("&lt;td&gt;&lt;b&gt;Instance&lt;/b&gt;&lt;/td&gt;\n")
                .append("&lt;/tr&gt;\n");
  
              if (tests instanceof List) {
                Collections.sort((List&lt;ITestResult&gt;) tests, comparator);
              }
  
              // User output?
              String id;
              Throwable tw;
  
              for (ITestResult tr : tests) {
                pw.append("&lt;tr&gt;\n");
  
                // Test method
                ITestNGMethod method = tr.getMethod();
  
                String name = method.getMethodName();
                pw.append("&lt;td title='").append(tr.getTestClass().getName()).append(".")
                  .append(name)
                  .append("()'&gt;")
                  .append("&lt;b&gt;").append(name).append("&lt;/b&gt;");
  
                // Test class
                String testClass = tr.getTestClass().getName();
                if (testClass != null) {
                  pw.append("&lt;br&gt;").append("Test class: ").append(testClass);
  
                  // Test name
                  String testName = tr.getTestName();
                  if (testName != null) {
                    pw.append(" (").append(testName).append(")");
                  }
                }
  
                // Method description
                if (! Utils.isStringEmpty(method.getDescription())) {
                  pw.append("&lt;br&gt;").append("Test method: ").append(method.getDescription());
                }
  
                Object[] parameters = tr.getParameters();
                if (parameters != null &amp;&amp; parameters.length &gt; 0) {
                  pw.append("&lt;br&gt;Parameters: ");
                  for (int j = 0; j &lt; parameters.length; j++) {
                    if (j &gt; 0) {
                      pw.append(", ");
                    }
                    pw.append(parameters[j] == null ? "null" : parameters[j].toString());
                  }
                }
  
                //
                // Output from the method, created by the user calling Reporter.log()
                //
                {
                  List&lt;String&gt; output = Reporter.getOutput(tr);
                  if (null != output &amp;&amp; output.size() &gt; 0) {
                    pw.append("&lt;br/&gt;");
                    // Method name
                    String divId = "Output-" + tr.hashCode();
                    pw.append("\n&lt;a href=\"#").append(divId).append("\"")
                      .append(" onClick='toggleBox(\"").append(divId).append("\", this, \"Show output\", \"Hide output\");'&gt;")
                      .append("Show output&lt;/a&gt;\n")
                      .append("\n&lt;a href=\"#").append(divId).append("\"")
                      .append(" onClick=\"toggleAllBoxes();\"&gt;Show all outputs&lt;/a&gt;\n")
                      ;
  
                    // Method output
                    pw.append("&lt;div class='log' id=\"").append(divId).append("\"&gt;\n");
                    for (String s : output) {
                      pw.append(s).append("&lt;br/&gt;\n");
                    }
                    pw.append("&lt;/div&gt;\n");
                  }
                }
  
                pw.append("&lt;/td&gt;\n");
  
  
                // Exception
                tw = tr.getThrowable();
                String stackTrace;
                String fullStackTrace;
  
                id = "stack-trace" + tr.hashCode();
                pw.append("&lt;td&gt;");
  
                if (null != tw) {
                  fullStackTrace = Utils.longStackTrace(tw, true);
                  stackTrace = "&lt;div&gt;&lt;pre&gt;" + Utils.shortStackTrace(tw, true)  + "&lt;/pre&gt;&lt;/div&gt;";
  
                  pw.append(stackTrace);
                  // JavaScript link
                  pw.append("&lt;a href='#' onClick='toggleBox(\"")
                  .append(id).append("\", this, \"Click to show all stack frames\", \"Click to hide stack frames\")'&gt;")
                  .append("Click to show all stack frames").append("&lt;/a&gt;\n")
                  .append("&lt;div class='stack-trace' id='").append(id).append("'&gt;")
                  .append("&lt;pre&gt;").append(fullStackTrace).append("&lt;/pre&gt;")
                  .append("&lt;/div&gt;")
                  ;
                }
  
                pw.append("&lt;/td&gt;\n");
  
                // Time
                long time = (tr.getEndMillis() - tr.getStartMillis()) / 1000;
                String strTime = Long.toString(time);
                pw.append("&lt;td&gt;").append(strTime).append("&lt;/td&gt;\n");
  
                // Instance
                Object instance = tr.getInstance();
                pw.append("&lt;td&gt;").append(Objects.toString(instance)).append("&lt;/td&gt;");
  
                pw.append("&lt;/tr&gt;\n");
              }
  
              pw.append("&lt;/table&gt;&lt;p&gt;\n");
  
            }
  
  }
  </code></pre>