user2635337
user2635337

Reputation: 231

how to create jar file using eclipse

I have a folder name called configurator which has many sub folders and class files. I need to create a configurator.jar file of this folder using eclipse. I followed below steps to create jar file.

  1. create a java project
  2. right click on project name, go to properties, go to java build path, click on source --> link source, browse and select configurator folder, add required external libraries --> click ok.
  3. Now, I am able to see the folder structure in navigator. Right click on configurator folder and select export
  4. select jar file and save the jar file in specified folder.

But, after saving the jar file, i am not able to see the class files inside the jar.

My question is: Why the class files not exported into the jar? How to do it using eclipse?

Upvotes: 18

Views: 107600

Answers (4)

marcin5
marcin5

Reputation: 1

Remember in Eclipse to run once your java class(as java application), and then you can export it to runnable jar (it will show in lunch configuration).

Upvotes: 0

Nava
Nava

Reputation: 29

Select Particular project, right click->Export

Under Java select JAR file, click on Next

(Don`t change any properties) select Jar file location where you want to save and click on Next

It will show JAR Package Options. Don`t make any changes, click on Next

Finally, select Main Class location. Select your particular class and then finish

Now your jar will be created in given location

Upvotes: 1

mehdi
mehdi

Reputation: 537

Creating a JAR file using Eclipse IDE:

Right click on your project, which you want to create a JAR file of. And select Export from the context menu.

Select JAR file from Java folder and click Next.

In eclipse Latest version Runnable JAR file is added.

Provide the Destination path and click on Finish to create the JAR.

Upvotes: 52

user3253107
user3253107

Reputation: 11

JAR files can be created using following method i have told

Example:

step1: Create One project and name it as a Project1

step2: Create another project and name it as a Project2

step3: Create packages for two projects

step4: Create classes for projects

step5: Right Click on Project1 go to export in that select Java go to jar files select Project1 then click ok and ok.

step6: Right Click on Project2 create one folder in that u have copy the jar file what we have created for project1.

step7: Right click on project2 go to properties select buildpath then click on libraries then click ok button then ok.

step 8: then type import package to the Project2

Your jar file is ready.

Upvotes: -6

Related Questions