Amazon Great Offers

May 03, 2012

Java: Create .jar file with .class file(s)

Hi friends,

Today, We had some trouble in using the .class file in java project. My colleague gave an idea of creating the .class to .jar file. So, We have created the .class file to .jar file, which solved our problem.

But one should know the package name of the .class file before creating the .jar file.

If the .class file is in some abc package. We have to place the .class file in a folder named abc.

In command prompt/terminal, go to the parent folder of abc.

Syntax: 
jar cf jar_file_name dir\{classname(s),*}

Example:

cmd> jar cf abc.jar abc\*

All the classes from abc folder will be now in abc.jar file

Now you can import the .jar file in any java project.
Post a Comment

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com