[英]How do I check installed JARs, external libraries, etc. on three different Java IDEs?
I've written programs in several languages and have tutored students in computer science, but just starting to learn Java on my MacBook. 我已经用多种语言编写了程序,并为计算机科学的学生提供了辅导,但是我才刚刚开始在MacBook上学习Java。 Regarding this question, I'd be happy with any answer that points me to available information or tutorials that address my question;
关于这个问题,我很乐意为我提供解决该问题的可用信息或教程的答案。 I'm capable of understanding advanced things.
我有能力理解高级知识。
I've been searching for the right IDE for me as well as something I can use with my students, and I've tried IntelliJ, Eclipse, and VS Code. 我一直在寻找适合我的IDE,以及我可以与学生一起使用的东西,并且我尝试了IntelliJ,Eclipse和VS Code。 Along the way I've installed external JARs to provide extra capabilities, such as Apache Commons.
在安装过程中,我安装了外部JAR以提供额外的功能,例如Apache Commons。
Things are getting confusing. 事情变得混乱了。 I've lost track of how I got to the present state in each IDE.
我忘记了如何在每个IDE中达到当前状态。 I'd like to understand better how to know the overall Java environment that any given project is using on each of these IDEs, including any external JARs and where they are located.
我想更好地了解如何了解任何给定项目在这些IDE的每一个上使用的总体Java环境,包括任何外部JAR及其位置。 And I'd like to know if they borrow from the Java system environment.
我想知道他们是否从Java系统环境中借用了。
My goal is to understand how my own system got to the way its currently configured, to update my configuration on a project-by-project basis, and to help my students get a matching configuration. 我的目标是了解我自己的系统如何达到当前配置的方式,在逐个项目的基础上更新我的配置,并帮助我的学生获得匹配的配置。
I'd also like advice on the right way, or simplest/cleanest way, to install external JARs. 我还希望以正确的方式(或最简单/最简洁的方式)安装外部JAR的建议。
Question : I'd also like advice on the right way, or simplest/cleanest way, to install external JARs.
问题 : 我还希望以正确的方式(或最简单/最简洁的方式)安装外部JAR的建议。
If you really wanna work in a organised way and wanna focus completely on coding rather than looking for dependencies to work with , then try building your projects with Apache Maven . 如果您真的想以一种有组织的方式工作并且想要完全专注于编码而不是寻找可以使用的依赖项,那么请尝试使用Apache Maven构建项目。 The magic wand of Maven projects are
pom.xml
file where all magic happens depending upon your wish. Maven项目的魔杖是
pom.xml
文件,根据您的意愿,所有魔咒都会发生。
Maven is a build automation tool used primarily for Java projects. Maven是主要用于Java项目的构建自动化工具。 Maven addresses two aspects of building software:
Maven解决了构建软件的两个方面:
Why Maven: 为什么选择Maven:
You can simply deploy your project as JAR , WAR , or EAR file and use it on different IDEs or as standalone. 您可以简单地将项目部署为JAR , WAR或EAR文件,并在不同的IDE上或独立使用它。
All IDEs need a way to know your project's dependencies. 所有IDE都需要一种了解项目依赖关系的方法。 You can either tell them that yourself or let a build tool do that.
您可以告诉他们自己,也可以让构建工具来完成。
Manual dependency handling: by adding the jars to your project. 手动依赖项处理:通过将jar添加到您的项目中。 This is probably the fastest way when working on a small project, with one developer, on a specific IDE, with few dependencies.
这可能是与一个开发人员,在特定IDE上,几乎没有依赖关系的小型项目一起工作时最快的方法。 Usually when telling the IDE that this .jar is a dependency of your project, the IDE stores that reference to a project-specific file (eg. in Eclipse the .classpath file which you can edit with a txt editor and see the dependencies yourself).
通常,当告诉IDE这个.jar是您项目的依赖项时,IDE会将该引用存储到特定于项目的文件中(例如,在Eclipse中,您可以使用txt编辑器编辑.classpath文件并亲自查看依赖项) 。 However, it kind of locks your application to your IDE.
但是,它会将您的应用程序锁定到IDE。 Most IDEs have cross-IDE support for import and migration, but using both IDEs at the same time can be confusing when a dependency is added to one and has to be repetitively added to other as well.
大多数IDE都具有跨IDE的导入和迁移支持,但是当将一个依赖项添加到一个依赖项并且必须重复添加到另一个依赖项时,同时使用这两个IDE可能会造成混淆。 Furthermore, your dependencies have dependencies on their own.
此外,您的依赖项本身具有依赖项。 By adding manually your jars you are responsible to find and download their own dependencies as well.
通过手动添加您的罐子,您有责任查找并下载它们自己的依赖项。
Use a build tool: There are 3 standard such tools right now: Apache Ant with Ivy , Apache Maven and Gradle . 使用构建工具:目前有3种标准的此类工具: Apache Ant with Ivy , Apache Maven和Gradle 。 All of them have support in the major IDEs for Java: IntelliJ IDEA, Eclipse and NetBeans.
它们都在主要的Java IDE中得到支持:IntelliJ IDEA,Eclipse和NetBeans。 All of them use some extra build-tool specific files to store your project's configuration and subsequently configure your IDE and the IDE-specific files.
它们都使用一些额外的特定于构建工具的文件来存储项目的配置,然后配置您的IDE和特定于IDE的文件。 That way, your project becomes IDE-agnostic, the IDE outsources the dependency handling to the build tool.
这样,您的项目就变得与IDE无关,IDE将依赖项处理外包给了构建工具。 These tools will download any direct or transitive dependencies of your project in a local directory or you can compile jars in a specified folder.
这些工具将在本地目录中下载项目的任何直接或传递依赖项,或者您可以在指定的文件夹中编译jar。 From those, Ant is the oldest (with Ivy adding dependency handling support), Maven was developed after that and Gradle is the newest and probably the most flexible.
从中可以看出,Ant是最老的(在Ivy中添加了依赖项处理支持),Maven是在那之后开发的,而Gradle是最新的并且可能是最灵活的。 In production however Maven is by far the most established one right now.
但是在生产中,Maven是目前最成熟的产品。 It would be also useful to look up the Standard Directory Layout .
查找“ 标准目录布局”也将很有用。 If you adhere to that, it will be easier to work/start with either Maven or Gradle.
如果您坚持这一点,那么使用Maven或Gradle可以更轻松地进行工作/启动。
Finally, you can search and find most of the free libraries in Maven-Central where conveniently their Ivy/Maven/Gradle script is added as well for you to use on your build-tool script. 最后,您可以在Maven-Central中搜索并找到大多数免费库,在这些库中可以方便地添加它们的Ivy / Maven / Gradle脚本,也可以在构建工具脚本中使用。 In many cases a .jar is provided as well if you prefer to manually add it as a dependency.
在许多情况下,如果您希望手动将其添加为依赖项,也将提供.jar。
Regarding VS Code, I think it supports these tools through plugins but I'm not sure. 关于VS Code,我认为它通过插件支持这些工具,但我不确定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.