简体   繁体   English

Eclipse Java库

[英]Eclipse java libraries

I'm kind of new to Eclipse and I'm hating it so far The question is I'm working on a small project with some classmates, we are using Eclipse and Git but every time someone does an immport all the libraries are lost because they are referencing the computers path like C:/someone/something.jar and then someone else push something to github and the libraries path C:/someone2/somthing.jar 我是Eclipse的新手,到目前为止,我一直很讨厌。问题是我正在和一些同学一起做一个小项目,我们正在使用Eclipse和Git,但是每次有人导入时,所有的库都会丢失,因为他们正在引用计算机路径,例如C:/someone/something.jar,然后其他人将某些内容推送到github和库路径C:/someone2/somthing.jar

Every time, I and my partners have to search for the libraries on our pc so the errors stop appearing. 每次,我和我的合作伙伴都必须在我们的PC上搜索库,以使错误不再出现。

Is there an easier way so we don't have to lose time searching for the libraries on our pc? 有没有更简单的方法,这样我们就不必浪费时间在PC上搜索库?

You need Java build tool like Maven , Gradle to manage your dependencies. 您需要MavenGradle之类的Java构建工具来管理依赖项。

In that way, it will resolve the libraries for you. 这样,它将为您解析库。 And in the source code, you should not check in .classpath , .project meta files. 并且在源代码中,您不应检入.classpath.project元文件。 Those files should be added into .gitignore to avoid commit. 这些文件应添加到.gitignore以避免提交。

To import projects into IDE (Eclipse in your case), Maven and Gradle can help you to generate those IDE meta files. 要将项目导入IDE(在您的情况下为Eclipse),Maven和Gradle可以帮助您生成这些IDE元文件。 Or some Eclipse plugins could be used to import maven or gradle project. 或者某些Eclipse插件可用于导入Maven或gradle项目。

You should create a folder for libraries and put all jar files in there, add these files to classpath using Java Build Path Option from project properties. 您应该为库创建一个文件夹,并将所有jar文件放在其中,然后使用项目属性中的Java Build Path Option将这些文件添加到classpath中。 Also add this folder to git 还要将此文件夹添加到git

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

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