Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because I found these answers unclear, here is what you need to do. First, if you package your code (IE your classes have the <code>package</code> keyword at the top) the compiled classes have to be in a directory with the same name as your package declaration in code. After you have compiled your classes, you need to <strong>move up a directory when you exectute the java command</strong>, and you <strong>include the name of the package</strong>. For example, if your code exists in <code>/myFolder/myPackage/</code> , and your class starts with <code>package myPackage</code> (note that the directory and the package are the same name), then you would do the following (linux / osx):</p> <pre><code>cd /myFolder/myPackage javac MyClass.java cd .. java myPackage.MyClass </code></pre> <p>Edit - A late edit to clarify something I see people get confused on. In the example above, the package is only one deep, meaning its just myPackage. If you code has a larger package, like</p> <pre><code>package com.somedomain.someproject; </code></pre> <p>you will need to execute the java command from the directory which contains the root directory for that package. For example if your compiled code is in myCode/com/somedomain/someproject/MyMainClass.class, then you will execute the java command from the myCode folder, like this (Again, take special note that the directory structure is the same as the package declaration):</p> <pre><code>cd /myCode java com.somedomain.someproject.MyMainClass </code></pre>
    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