kieranhill98
kieranhill98

Reputation: 11

How to import .class files into eclipse

I have a .jar on my desktop that my friend coded. I ahve opened the .jar in winrar to get all the .class files and things like that for it. How would i add them to a package in Eclipse.

If this is not possible is there anyway i can just open a .project file?

Thanks.

Upvotes: 1

Views: 2530

Answers (3)

Tareq Salah
Tareq Salah

Reputation: 3718

project -> properties -> java build path -> libraries -> add external jars

I hope that will work

If you want to decompile your .class and use it as code, you can look at this question

How do I "decompile" Java class files?

Upvotes: 1

Jorge_B
Jorge_B

Reputation: 9872

In your place, I would just copy the .jar as is somewhere in your project and add it as a dependency by:

Right-click on project -> Project properties -> Java Build Path -> Libraries -> Add JARs...

That way you can build new code depending on your friend's code.

I assume you are just beginning with Java or Eclipse, when you feel yourself more comfortable you may be interested in learning dependency management with automated tools as Ivy, Maven or Gradle

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html http://www.gradle.org/docs/current/userguide/dependency_management.html http://ant.apache.org/ivy/history/latest-milestone/reference.html

Upvotes: 1

lviggiani
lviggiani

Reputation: 6066

Supposing that jar is a library you want to use, import It into your project root then go to build path and select import jar to link to it

Upvotes: 0

Related Questions