Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a variation of the "common beginners error" with running Java programs from the command line.</p> <blockquote> <p>java test or java -classpath directory test or java -cp . test it throws "Exception in thread main java.lang.NoClassDefFoundError: test (wrong name: deem/test).</p> </blockquote> <p>The JVM is in effect telling you that found "test.class" on the search path, but when it read class file, it concluded that the file <em>should</em> have been at "./deem/test.class" or "directory/deem/test.class" ... depending on which "-cp" / "-classpath" argument you <em>actually</em> used</p> <blockquote> <p>If I use java deem.test it says: Error, could not find or load main class deem.main</p> </blockquote> <p>This is now telling you that it cannot find "deem/main.class".</p> <p>Note that you have <em>now</em> told it to look for a class called "deem.main" instead of "test" or "deem.test". (Or perhaps you just transcribed something incorrectly there.)</p> <p>The rules are really rather simple:</p> <ol> <li>You must give the <strong>fully qualified</strong> class name to <code>java</code> as the first argument after the options. (<em>Not</em> the simple class name. <em>Not</em> the ".class" file name. <em>Not</em> the name of the entry point method.)</li> <li>You must specify the classpath such that the <code>java</code> command can <ul> <li>map the class name into a relative pathname for the class file (e.g. <code>foo.bar.baz.MyClass</code> maps to <code>foo/bar/baz/MyClass.class</code>) ... </li> <li>and then resolve that relative path against one of the classpath entries; e.g. if <code>.</code> is the classpath, then <code>./foo/bar/baz/MyClass.class</code>.</li> </ul></li> <li>The class must have the required <code>public static void main(String[])</code> entry point method.</li> </ol> <p>So <strong>IF</strong> ...</p> <ol> <li>the fully qualified class name of your class is <code>deem.test</code>; i.e. the <code>test</code> class is in the package <code>deem</code>, <strong>AND</strong></li> <li>the corresponding class file is in <code>./deem/test.class</code>, <strong>AND</strong></li> <li>it has the required entry point method, <strong>AND</strong></li> <li>the test application doesn't depend on other classes of yours or 3rd party libraries ...</li> </ol> <p><strong>THEN</strong> <code>java -cp . deem.test</code> should work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload