title: What is the correct way to create a Java package from command line? (trouble with Maven)
body: <p><strong>[ SOLVED ] - but still looking for explanation. Please see bottom of question</strong></p>
  
  <hr>
  
  <p>I don't have much experience with command line or with Maven. I'm working on a tutorial from a book. It state I should create a java file</p>
  
  <pre><code>src/main/java/com/effectivemaven/chapter01/ExampleAction.java
  </code></pre>
  
  <p>What I did was <strong><code>mkdir</code></strong> each directory separately i.e. <code>mkdir com</code>, <code>mkdir effectivemaven</code>, <code>mkdir chapter01</code></p>
  
  <p>I create the .java file in the <code>chapter01</code> directory.  </p>
  
  <pre><code>package com.effectivemaven.chapter01;
  
  import org.slf4j.*;
  
  public class ExampleAction {
      final Logger logger = LoggerFactory.getLogger(ExampleAction.class);
  
      public boolean execute() {
          logger.info( "Example Action Executed." );
          return true;
      }
  }
  </code></pre>
  
  <p>When I <code>mvn compile</code>, it says <code>compiling 1 file to target...</code>, but when I look at the taget directory, nothing is created.</p>
  
  <p>So I tried to create a another .java file without using packages, just a simple</p>
  
  <pre><code>public class Hello {
      public static void main(String[] args) {
          System.out.println("Hello");
      }
  }
  </code></pre>
  
  <p>in the <code>java</code> directory, then <code>mvn compile</code> and it shows up in the <code>target</code> file.</p>
  
  <p>So my assumption is that I'm not creating the packages correctly by using <code>mkdir</code>, or possibly I'm doing something else wrong I'm unaware of.</p>
  
  <blockquote>
    <p><strong>So basically I just want to know, what is the correct way to create a package from the command line? And if I'm doing it correctly, what could be the other possible reasons the <code>.class</code> is not being created in the <code>target</code>?</strong></p>
  </blockquote>
  
  <hr>
  
  <p><strong>EDIT</strong> tree</p>
  
  <pre><code>first-webapp
            src
               main
                   java
                       Hello.java
                       com
                          effectivemaven
                                       chapter01
                                               ExampleAction.java
            target
                 classes
                       Hello.class
            pom.xml
  </code></pre>
  
  <p>Command running from <code>C:\Maven Book\first-webapp&gt;</code></p>
  
  <pre><code>C:\Maven Book\first-webapp&gt;mvn compile
  [INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building first-webapp Maven Webapp 1.0-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ first-weba
  pp ---
  [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
  i.e. build is platform dependent!
  [INFO] Copying 0 resource
  [INFO]
  [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ first-webapp
  ---
  [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
  uild is platform dependent!
  [INFO] Compiling 2 source files to C:\Maven Book\first-webapp\target\classes
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 3.667s
  [INFO] Finished at: Sun Jan 12 00:09:49 PST 2014
  [INFO] Final Memory: 11M/111M
  [INFO] ------------------------------------------------------------------------
  C:\Maven Book\first-webapp&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong> pom.xml as requested</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.underdogdevs.webapp&lt;/groupId&gt;
      &lt;artifactId&gt;first-webapp&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;first-webapp Maven Webapp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;1.7.5&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;finalName&gt;first-webapp&lt;/finalName&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <hr>
  
  <p>By the way, this is a web-app I created with the following command</p>
  
  <blockquote>
    <p><code>mvn archetype-generate -DgroupId=com.underdogdevs.webapp -DartifactId=first-webapp -DarchetypeArtifactid=maven-archetype-webapp</code></p>
  </blockquote>
  
  <hr>
  
  <p><strong>[ SOLVED ] - but with very mimimal understanding</strong> - still offering brownie points for anyone who can explain to me this behavior. Below is what I did</p>
  
  <blockquote>
    <p>I got it to work. Since I create the project with <code>groupId=com.underdogdevs.webapp</code>, I tried to make a package <code>com\underdogdevs\webapp</code> and created a the class with the corresponding package reference. This fixed the problem. The class appears. But I tested it even further and deleted the package I just created and tried to clean and compile with only the original package structure, but the file showed up again in the orginal package structure. I have no idea why this happens though.Anyone have any ideas?</p>
  </blockquote>