I have a java project build using Maven "quickstart" template. The structure looks like
src
main
java
myapp
HelloWorld.java
The HelloWorld.java is declared to be under package "myapp"
inside pom.xml, only junit is included.
Now, after I run maven compile, I get a class file under
target
classes
myapp
HelloWorld.class
but after I cd to target/classes/myapp, and do
java -cp . HelloWorld
I get NoClassDefFoundError, i did it according to How to execute a java .class from the command line
I tried
java -cp . myapp.HelloWorld (myapp is the package)
I still get "could not find or load main class"
My question is: I set the classpath using "-cp .", then why i still can't run the class? does it has anything to do with Maven?
I know I don't need to use command line, I am just curious.