1832928 Members
2372 Online
110048 Solutions
New Discussion

Re: jar files

 
oiram
Regular Advisor

jar files

Hello:

When I make a jar -tvf of some files I see the following:

name.class
name$1.class
name$2.class

Does any of you know what means the $1, $2 ... after the name of the files.

Thanks,
Mario.
3 REPLIES 3
Mike Stroyan
Honored Contributor

Re: jar files

You get one of those "name$n.class" files for each anonymous inner class of class "name".
Robert-Jan Goossens
Honored Contributor

Re: jar files

HI Mario,

How to create a JAR file

To make a JAR file:

JAR CVF my.jar *.class

You have to indicate which class is the entry point in the JAR file. You are doing this by adding a Main-Class header to the JAR file's manifest. The header takes the form:

Note: Note classes with the name *$1.class is automatically created when you compile. These files must be included in the JAR file.

Hope it helps,

Robert-Jan.
Khalid A. Al-Tayaran
Valued Contributor

Re: jar files


Hi,

One more thing:

You can re-create the .class file again in case you loose them. Just recompile the .java files and create jar files if you want to.