Java Archive (JAR) files allow developers to package many classes into a single file. JAR files also use compression, so this can make applets and applications smaller. If you are not using any IDE or ANT, you may like to read the following:Creating a .JAR file is easy. Simple go to the directory your classes are stored in and type :-jar -cf yourJarFileName.jar *.classIf your application or applet uses packages, then you'll need to do things a little differently. Suppose your classes were in the package yourcode.games.CoolGame - you'd change to the directory above yourcode and type the following :- (Remember to use / on UNIX systems)jar -cf yourJarFileName.jar .\yourcode\games\CoolGame\*.classNow, if you have an existing JAR file, and want to extract it, you'd type the followingjar -xf yourJarFileName.jarWorking with JAR files isn't that difficult, especially if you've used the unix 'tar' command before. If you're planning on packaging an applet for Internet Explorer, or an application for Microsoft's jview, you might also want to consider .CAB files.
具体怎么用你可以去csdn上下载一个ANT的教程
输入jar -vcf 向成生jar包的名 需要打包的文件的地址
If you are not using any IDE or ANT, you may like to read the following:Creating a .JAR file is easy. Simple go to the directory your classes are stored in and type :-jar -cf yourJarFileName.jar *.classIf your application or applet uses packages, then you'll need to do things a little differently. Suppose your classes were in the package yourcode.games.CoolGame - you'd change to the directory above yourcode and type the following :- (Remember to use / on UNIX systems)jar -cf yourJarFileName.jar .\yourcode\games\CoolGame\*.classNow, if you have an existing JAR file, and want to extract it, you'd type the followingjar -xf yourJarFileName.jarWorking with JAR files isn't that difficult, especially if you've used the unix 'tar' command before. If you're planning on packaging an applet for Internet Explorer, or an application for Microsoft's jview, you might also want to consider .CAB files.