title: how to compile java files in linux with a package
body: <p>I am able to compile my Main.java file without any issues in Eclipse.</p>
  
  <p>Inside Main.java I have</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.selenium.zLoadProfilerPkg;
  </code></pre>
  
  <p>Inside the other 3 files I also have</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.selenium.zLoadProfilerPkg;
  </code></pre>
  
  <p>However when I upload the whole structure to linux, and I try to compile it, I get errors:</p>
  
  <pre><code>[sgalkov@zpub zLoadProfilerPkg]$ pwd
  /home/sgalkov/zpp_tech_git_checkout/profiler/zLoadProfiler/zLoadProfiler/src/com/selenium/zLoadProfilerPkg
  [sgalkov@zpub zLoadProfilerPkg]$ cd /home/sgalkov/zpp_tech_git_checkout/profiler/zLoadProfiler/zLoadProfiler/src/com/selenium/zLoadProfilerPkg/; javac -cp ".:/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/selenium-java-2.30.0.jar:/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/libs/*:/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/selenium-server-standalone-2.30.0.jar:/home/sgalkov/zpp_tech_git_checkout/profiler/browsermob-proxy-2.0-beta-7/browsermob-proxy-2.0-beta-7-sources.jar:/home/sgalkov/zpp_tech_git_checkout/profiler/browsermob-proxy-2.0-beta-7/lib/*:/home/sgalkov/zpp_tech_git_checkout/profiler/zLoadProfiler/zLoadProfiler/src/com/selenium/zLoadProfilerPkg" Main.java
  Main.java:54: error: cannot find symbol
      BrowsermobProxy bmp = new BrowsermobProxy(PROXY_API_HOST, PROXY_API_PORT);
      ^
  symbol:   class BrowsermobProxy
  location: class Main
  
  Main.java:54: error: cannot find symbol
      BrowsermobProxy bmp = new BrowsermobProxy(PROXY_API_HOST, PROXY_API_PORT);
                                ^
  symbol:   class BrowsermobProxy
  location: class Main
  
  Main.java:310: error: cannot find symbol
          HarStorage hs = new HarStorage(HARSTORAGE_HOST, HARSTORAGE_PORT);
          ^
  symbol:   class HarStorage
  location: class Main
  
  Main.java:310: error: cannot find symbol
          HarStorage hs = new HarStorage(HARSTORAGE_HOST, HARSTORAGE_PORT);
                              ^
  symbol:   class HarStorage
  location: class Main
  
  4 errors
  [sgalkov@zpub zLoadProfilerPkg]$
  </code></pre>
  
  <p>If I comment out "package com.selenium.zLoadProfilerPkg;" in each of the 4 files and compile them one by one, everything works fine.</p>
  
  <p>Also, If I try to compile it this way:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>cd /home/sgalkov/zpp_tech_git_checkout/profiler/zLoadProfiler/zLoadProfiler/src/com/selenium/zLoadProfilerPkg/;
  
  javac -cp ".\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/selenium-java-2.30.0.jar\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/libs/*\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/selenium-2.30.0/selenium-server-standalone-2.30.0.jar\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/browsermob-proxy-2.0-beta-7/browsermob-proxy-2.0-beta-7-sources.jar\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/browsermob-proxy-2.0-beta-7/lib/*\
  :/home/sgalkov/zpp_tech_git_checkout/profiler/zLoadProfiler/zLoadProfiler/src/com/selenium/zLoadProfilerPkg" \
  BrowsermobProxy.java HarStorage.java HttpRequest.java Main.java
  </code></pre>
  
  <p>it does compile but I am getting an extra class for Main.java</p>
  
  <pre><code> rw-r--r-- 1 sgalkov users  1422 Mar 11 20:30 Main$1.class
   rw-r--r-- 1 sgalkov users  8264 Mar 11 20:30 Main.class
   rw-r--r-- 1 sgalkov users 14864 Mar 11 19:32 Main.java
  </code></pre>
  
  <p>and I am unable to run the program, I get the error:</p>
  
  <pre><code> Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: com/selenium/zLoadProfilerPkg/Main)
      at java.lang.ClassLoader.defineClass1(Native Method)
  </code></pre>
  
  <p>I've looked around and tried various options but can't get this project to compile and would appreciate any pointers.</p>