Reputation: 4291
I cannot understand why in Eclipse
after these two steps
Run as
-> Maven clean
Project
-> clean...
I can still run my program using green icon with white arrow?
I thought there are no .class
files after cleaning. I was expecting exception like ClassNotFound
, but nothing like this happened.
Do you know how to properly clean project in Eclipse
?
Upvotes: 2
Views: 1104
Reputation: 2755
I just checked this phenomenon out with one of my Maven
projects in Eclipse
and this is what I observed. By the way, don't trust what you see in the Package View
, use your file system explorer.
Run as -> Maven clean : deletes the target folder
Project -> clean... : creates target
folder with empty subfolders "classes
" and "test-classes
". In Eclipse's
Package Explorer
view, I see an empty target folder.
At this point I would say the proper way to clean a Maven
project in Eclipse
is simply to do Run as -> Maven
clean.
Now to address why your program runs after cleaning. As soon as I ran a program in the project, Eclipse
compiled and populated the "target/classes
" and "target/test-classes
" folders with *.class files and resources. In Eclipse's
Package Explorer
view, I still see an empty target folder.
The trick to figuring this out was to look at the project directory and sub directories with the system file explorer and not just with Eclipse's
Package View
or Project View
.
Upvotes: 1
Reputation: 490
In starting code for your application you can add:
System.out.println("Classpath=" + System.getProperty("java.class.path"));
you can analyze it (nornally I use notepaddpp to split it by classpath separator and sort) - maybe it refers to jars in maven repo which contains classes as well? Sometime class folders are first on classpath and thus are before jars even if in jars there are the same classes.
Upvotes: 1
Reputation: 115328
Clean in eclipse is not the same as clean in maven.
Maven's clean indeed removes all compiled resources (classes etc).
Clean project in eclipse is a kind of mvn clean compile
, i.e. it removes *class
files and compiles all *.java
files again.
Upvotes: 3
Reputation: 1929
This is probably because eclipse will auto build your project when you run it
Upvotes: 0