Java source won't compile as soon as I put it in a package?

I installed Maven on my archlinux desktop. I have a perplexing issue.

Following the getting started guide and installing Maven, at the end of it all I had the default company set to zerovector (instead of my-company.) So the directory structure (and package) looks like this: src/com/zerovector/app (or

App just says "Hello World" mvn compile fails. mvn build fails. NoClassDefFound errors when I try to run the product of Maven's processes. Trying to compile it manually (javac fails with NoClassDefFound. As soon as I remove the package; line suddenly it compiles and works. I can go javac and it compiles just fine into App.class (simple Hello World prog.) And this App.class does it's little "Hello World" and exits fine.

Why is the package line throwing java for a bunch of nonesense? Can I fix this or am I going to have to manually code/organize and forget Maven and Packages?


With Maven, the Java class code should be in the directory src/main/java/com/zerovector/app and not in src/com/zerovector/app. If you don't want to use the default source directory you have to change the configuration.

If you use javac then don't change your current directory to src/main/java/com/zerovector/app but stay in the source root directory:

 cd src/main/java
 javac com/zerovector/app/

If you follow this rule, the package declaration and the relative path to the Java source file match and everything works. If you change your current directory to the place where the Java Source file is, then the compiler expects no package (= default package):

cd src/main/java/com/zerovector/app/

Need Your Help

php with jquery html pop up

php jquery html css

this is actually a part of huge project so i didnt include the css but im willing to post it here if actually necessary.

How to convert correlated sub query containing duplicate table to non-correlated one?

sql database performance subquery informix

I have to convert the correlated sub-query to non-correlated sub-query cuz of performance issues .