title: How to run TestNG from command line
body: <p>How exactly do I run a .java TestNG project from a command line?</p>
  
  <p>I have read through the TestNG documentation, and tried the following to no avail: </p>
  
  <pre><code>C:\projectfred&gt; java org.testng.TestNG testng.xml 
  </code></pre>
  
  <p>... with the following testng.xml file in my project:</p>
  
  <pre><code>&lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" &gt;  
  &lt;suite name="SuiteAll" verbose="1"&gt;
      &lt;test name="TestAll"&gt;  
          &lt;packages&gt;  
              &lt;package name="com.project.fred.tests"/&gt;
          &lt;/packages&gt;  
      &lt;/test&gt;  
  &lt;/suite&gt;
  </code></pre>
  
  <p>The error I get is this: </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
  Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
  Could not find the main class: org.testng.TestNG.  Program will exit.
  </code></pre>
  
  <p>Obviously, I am not referencing TestNG correctly in my command line.  Does anyone know how to get this working?</p>