Java 已经在 netbeans 中导入了 jar 文件,但我的源找不到库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18431741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:34:36  来源:igfitidea点击:

Already imported the jar files in netbeans but my source cannot find the library

javanetbeans

提问by jax

I already imported the jar files in netbeans but my main java file still cannot find the methods. I am using netbeans 7.3.1 on Mac. Does anyone know how make it work?

我已经在 netbeans 中导入了 jar 文件,但我的主 java 文件仍然找不到方法。我在 Mac 上使用 netbeans 7.3.1。有谁知道如何使它工作?

Thank you,

谢谢,

采纳答案by dantuch

I also had problem with importing classes from imported jar. It was so damn annoying...

我也有从导入的 jar 导入类的问题。真是烦死了...

There are couple solutions @ web, (clear cache in user's AppData. or make sure to add jar's properly - by using "Add Jar/Folder..." option) but none of them worked for me.

有几个解决方案@ web,(清除用户 AppData 中的缓存。或确保正确添加 jar - 通过使用“添加 Jar/文件夹...”选项),但没有一个对我有用。

What worked was newproject and importing THE SAME (that's sad) jar files into it. So I had 2 project with exactly the same contents, but only one of them was working (compiling).

有效的是项目并将相同的(可悲的)jar 文件导入其中。所以我有 2 个项目,内容完全相同,但只有一个在工作(编译)。

EDIT:However, your problem is not related to mine. Root cause of your issue is the jar itself.

编辑:但是,您的问题与我的无关。问题的根本原因是罐子本身。

It contains class files in default package that is making them impossible to import.

它包含默认包中的类文件,这使得它们无法导入

Read here how to import class from default (unnamed) package.

在此处阅读如何从默认(未命名)包导入类

回答by user3059905

hey guyes just keep your .jar files in the "C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext" it will work definitely.I have tried all the other options but i finally copied my .jar files in above path and it worked.

嘿,伙计们只需将您的 .jar 文件保存在“C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext”中,它肯定会起作用。我已经尝试了所有其他选项,但我终于复制了我的 .jar 文件在上面的路径中,它起作用了。