简体   繁体   中英

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.

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

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?

假设jar是您要使用的库,将其导入到项目根目录,然后转到构建路径并选择import jar链接到它

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM