简体   繁体   English

如何将.class文件导入eclipse

[英]How to import .class files into eclipse

I have a .jar on my desktop that my friend coded. 我的朋友在我的桌面上编码了一个.jar。 I ahve opened the .jar in winrar to get all the .class files and things like that for it. 我在winrar中打开.jar来获取所有.class文件以及类似的内容。 How would i add them to a package in Eclipse. 我如何将它们添加到Eclipse中的包中。

If this is not possible is there anyway i can just open a .project file? 如果这是不可能的,无论如何我只能打开一个.project文件?

Thanks. 谢谢。

In your place, I would just copy the .jar as is somewhere in your project and add it as a dependency by: 在您的位置,我只需按原样复制.jar并通过以下方式将其添加为依赖项:

Right-click on project -> Project properties -> Java Build Path -> Libraries -> Add JARs... 右键单击项目->项目属性-> Java构建路径->库->添加JAR ...

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 我假设您刚开始使用Java或Eclipse,当您感到更自在时,您可能会对使用Ivy,Maven或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 http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html http://www.gradle.org/docs/current/userguide/dependency_management.html http://ant.apache。组织/常春藤/历史/最新里程碑/的reference.html

project -> properties -> java build path -> libraries -> add external jars 项目->属性-> Java构建路径->库->添加外部jar

I hope that will work 我希望那能起作用

If you want to decompile your .class and use it as code, you can look at this question 如果您想反编译.class并将其用作代码,则可以查看此问题

How do I "decompile" Java class files? 如何“反编译” Java类文件?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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