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.

2 comments:

Suresh Raju Pilli said...

Hi Parks,
Thanks for visiting my blog. You will get lot of free videos online for Java. No need to spend money on online tutorials. Scope of java training is not limited. You will be learning new topics when they are required by you. Please follow the Complete Reference and J2EE for Dummies, Deitel and Deitel, Head first Java to get a better idea of the topics and examples.

ganesh said...

I actually enjoyed reading through this posting.Many thanks.


Java Training Courses

Featured Post

Java Introdcution

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