When I compile a jar with maven, but when I unzip it, it generates me copies of several files with the symbol $.class
, how can I omit this type of copies?
Example:
dao.class
dao$1.class
When I compile a jar with maven, but when I unzip it, it generates me copies of several files with the symbol $.class
, how can I omit this type of copies?
Example:
dao.class
dao$1.class
Imagine you have a class like
class A { ...}
That you keep in A.java
. This generates when compiling a file A.class
.
Now imagine that you also have an interface (or class) like this:
interface B {
public void hola();
}
That you keep in B.java
. This generates when compiling a file B.class
.
And, to complete this example, imagine that in your class A
you need an object that meets B
, so you declare an anonymous class :
class A {
private B b= new B() {
public void hola() { };
};
}
Your attribute B is a class that meets interface B, but it is not a class B, but an anonymous class (without a name), so the compiler saves it in A$1.class
, because it is a class created within A.
If you delete that file, your program will stop working and launch a ClassNotFoundException
.