简体   繁体   English

如何在三个不同的Java IDE上检查已安装的JAR,外部库等?

[英]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的建议。

Maven Maven的

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解决了构建软件的两个方面:

  • Describes and manages how software is built. 描述和管理软件的构建方式。
  • Describes and manages dependencies (various libraries used by your code). 描述和管理依赖关系(代码使用的各种库)。

Why Maven: 为什么选择Maven:

  1. De facto standard 事实标准
  2. Able to compile, test, pack and distribute source code ( different Goals ) 能够编译,测试,打包和分发源代码(不同的目标
  3. Robust dependency management (Most important from my point of view) 强大的依赖关系管理(从我的角度来看最重要)
  4. Extensible via plugin 可通过插件扩展
  5. Good community support and many fan boys around. 良好的社区支持,周围有很多球迷。
  6. The big 3 IDEs (IntelliJ, NetBeans, and Eclipse) all having good support for Maven, letting you use Maven as a substitute for their own proprietary project definition and build process. 三大IDE(IntelliJ,NetBeans和Eclipse)都对Maven都有很好的支持,因此您可以使用Maven替代其自己的专有项目定义和构建过程。
  7. Maven famously caches all of its dependencies in the ~/.m2 directory, which is sometimes called the local Maven repository. Maven著名地将其所有依赖项缓存在〜/ .m2目录中,该目录有时称为本地Maven存储库。 Maven local repository keeps your project's all dependencies (library jars, plugin jars etc.). Maven本地存储库保留了项目的所有依赖项(库jar,插件jar等)。 When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. 当您运行Maven构建时,Maven会自动将所有依赖项jar下载到本地存储库中。 It helps to avoid references to dependencies stored on remote machine every time a project is build. 它有助于避免在每次构建项目时都引用存储在远程计算机上的依赖项。

You can simply deploy your project as JAR , WAR , or EAR file and use it on different IDEs or as standalone. 您可以简单地将项目部署为JARWAREAR文件,并在不同的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 IvyApache MavenGradle 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.

相关问题 如何导出带有外部JAR,图像,声音文件,字体,dll等的Eclipse项目? - How do I export an Eclipse project with external JARs, images, sound files, fonts, dlls, etc.? 外部Java库(罐子)实际上如何工作? - How do external java libraries(jars) actually work? 单击一次按钮时执行操作,而单击两次,三次等时执行其他操作。(Netbeans,Java) - Perform action when button clicked once and do a different action when clicked twice, three times etc. (Netbeans, Java) 你如何处理不同的Java IDE和svn? - How do you handle different Java IDEs and svn? 如何在Java中查看内置类的源代码(例如BigInteger等)? - How do I view source code of built-in classes in Java (e.g. BigInteger etc.)? 如何在IntelliJ Java Swing表单中调整标签,文本字段等的大小? - How do I resize labels, text fields, etc. in the IntelliJ Java Swing form? 如何使用Apache POI(Java)在Excel中创建表单控件(单选按钮,复选框,按钮等)? - How do I create form controls (radio, checkbox, buttons, etc.) in Excel using Apache POI (Java)? 如何使GUI中的对象(文本字段等)消失? - How do I make objects (textfields etc.) in the GUI disappear? IntelliJ:在没有字符串/注释/等的情况下如何重构? - IntelliJ: How do I refactor without strings/comments/etc.? 如何找出项目的依存关系? (它使用什么jar /库等) - How can I figure out the dependencies of a project? (What jars/libraries it uses etc)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM