将jar库添加到项目Intellij IDEA [英] Adding jar library to project Intellij IDEA

查看:206
本文介绍了将jar库添加到项目Intellij IDEA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将jar库链接到我的项目,但它似乎并没有完全工作..



我用过Project结构(shift + ctrl + alt + S)添加stdlib.jar,并且库似乎链接到Project结构窗口的Modules - Dependencies选项卡上的程序模块(对不起,我无法添加图像,需要10 rep)



当我在项目的src文件夹中创建一个类时,我可以使用stdlib.jar中的类/方法,但是当我在src中创建一个包时然后在这个包中创建新类,我不能使用stdlib.jar中的方法。



Intellij也没有提供任何导入任何东西的建议,我也没有我真的知道应该写什么import语句(如果这是我需要的),因为stdlib.jar是jar文件的名称,而不是包/类名。



<我也是编程新手,但这个问题是关于如何管理Intellij Idea IDE。



值得4小时的挫折n,但我找不到解决方案。



我读过配置模块依赖关系和库,但找不到我的问题的确切答案。我也阅读了很多stackoverflow主题。



更新:
这是指向stdlib.jar的链接。它来自Sedgewick关于算法的书籍。



UPDATE2:
看来stdlib.jar似乎是为默认包设计的,不能在里面使用任何其他包(现在的问题是:为什么他们喜欢这样做而不是制作通用库?)。但是这样的信息不在每本书中。

解决方案

我也在学习这本书。



您只需转到项目结构,然后在左侧面板中选择模块,然后单击依赖关系选项卡。添加 stdlib.jar ,它就可以了。


I've tried to link a jar-library to my project, but it doesn't seem to "completely" work..

I've used Project structure (shift+ctrl+alt+S) to add stdlib.jar, and the library seems to be linked to the program module on the Modules - Dependencies tab of the Project structure window (Sorry, I can't add images, need 10 rep)

When I create a class in the src folder of the project, I can use the classes/methods from stdlib.jar, but when I create a package inside src and then create new classes inside this package, I can't use the methods from stdlib.jar.

Intellij also gives no proposals to import anything, and I don't really know what import statement should I write (if this is what I need) since stdlib.jar is the name of the jar-file, but not the package/class name.

I'm also new to programming, but this question is about how to manage Intellij Idea IDE.

It was worth 4 hours of frustration, but I couldn't find a solution.

I've read Configuring Module Dependencies and Libraries, but couldn't find the exact answer for my problem. I've read many stackoverflow topics as well.

UPDATE: Here is the link to stdlib.jar. It is from the Sedgewick's booksite on algorithms.

UPDATE2: It really seems that stdlib.jar was designed for the default package and can't be used inside any other package (now the question is: why they do like this instead of making "universal" libraries?). But such infos are not in every book.

解决方案

I am learning this book, too.

You simply go to "Project Structure" and then select "Modules" on the left panel, and click on the "Dependencies" tab. Add stdlib.jar to it, and it just works.

这篇关于将jar库添加到项目Intellij IDEA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆