[英]Adding external .jar file in Eclipse
I'm having trouble adding a.jar file I downloaded for my Java project.我在添加为我的 Java 项目下载的文件时遇到问题。 This is really the first time I've used eclipse, so please bear with me and for some reason (I have no clue why), I just find it somewhat confusing.
这真的是我第一次使用 eclipse,所以请多多包涵,出于某种原因(我不知道为什么),我只是觉得有点混乱。
I know that in order reference different class files you simply need to create a class library and add it to the build path.我知道为了引用不同的 class 文件,您只需创建一个 class 库并将其添加到构建路径中。 From there, all which needs to be done (unless I'm misunderstanding this for whatever reason) is use the "import" keyword to import whatever.jar, .java, or.class/.interface file necessary into the project.
从那里,所有需要做的事情(除非我出于某种原因误解了这一点)是使用“import”关键字将任何东西导入到项目中。jar、.java 或 .class/.interface 文件。
I've tried that with my.jar.我已经用 my.jar 试过了。 I have it referenced in the build path (all I did was just copy the jar to the project directory, and then use the build path option to add it externally), but when ever try to call the object "Delegator", which obviously is a part of the.jar file, it won't read.
我在构建路径中引用了它(我所做的只是将 jar 复制到项目目录,然后使用构建路径选项将其添加到外部),但是当尝试调用 object “委托人”时,这显然是.jar 文件的一部分,它不会读取。
Am I missing something here?我在这里错过了什么吗? Seriously, anyone who knows the answer to this - you're relieving a mother of a headache.
说真的,任何知道这个答案的人 - 你正在缓解一个头痛的母亲。 And before anyone asks - yes, I've searched this one to death.
在任何人问之前 - 是的,我已经把这个找死了。 I've found similar questions, but nothing which quite hit what I was looking for.
我发现了类似的问题,但没有什么能完全符合我的要求。 Either that, or I really just lack the common sense.
要么,要么我真的缺乏常识。
Right click on project->BuildPath->Libraries->Addexternaljar and then press ok and if it doesnot worked then you should go to the右键单击项目->BuildPath->Libraries->Addexternaljar ,然后按确定,如果它不起作用,那么你应该 go 到
Order and Export taband checked the jar you have just added in your project.
There are several possible reasons, for the question hasn't mentioned the specific failure, and where it has occurred.有几个可能的原因,因为问题没有提到具体的失败,以及它发生在哪里。 The following is a list of possible reasons I could think of, but this may not be exhaustive:
以下是我能想到的可能原因列表,但这可能并不详尽:
Note:笔记:
Update更新
Every Java application needs a main(String[] args]
method to start execution. This is the entrypoint for the application. From the comment, it appears that the main method is in a different class. If so, the said class ought to be used to start the application. In Eclipse, a "Run configuration" might be used for the class that lacks this entrypoint, resulting in the described error. One can rectify this by creating a new Run configuration for the class with the said entrypoint. This may be done by one of the following:每个 Java 应用程序都需要一个
main(String[] args]
方法来开始执行。这是应用程序的入口点。从评论中,似乎 main 方法位于不同的 class 中。如果是这样,则所述 ZA2F2ED4F298EBC2CBB1DZC2 应该是用于启动应用程序。在 Eclipse 中,“运行配置”可能用于缺少此入口点的 class,导致所描述的错误。可以通过为 ZA2F2ED4F8EBC2CBBDZC21A2 创建新的运行配置来纠正此问题。可以通过以下方式之一完成:
Alt+Shift+X+J
shortcut) from the said class.Alt+Shift+X+J
快捷方式)。i was facing similar issue with spring jar files but then tried with different jar files and it work so I think, classes defined in jar files were private and not available outside of jar hence you were not able to access the file. i was facing similar issue with spring jar files but then tried with different jar files and it work so I think, classes defined in jar files were private and not available outside of jar hence you were not able to access the file.
thanks, Raju Rathi谢谢, 拉朱拉蒂
Right click on the project--->Build Path--->Configure Build Path...--->In left side you have to choose Java Build Path--->Libraries--->Add External JARs--->ok--->ok右键单击项目--->构建路径--->配置构建路径...--->在左侧你必须选择Java构建路径--->库--->添加外部JARs--- >好的--->好的
Steps to add jar file in eclipse 1. right click on project 2. click on Bulid Path->configure path 3. click on java Build path 4. Click on libraries tab 5. click on add external jar tab 6. choose jar file 7 click on ok Steps to add jar file in eclipse 1. right click on project 2. click on Bulid Path->configure path 3. click on java Build path 4. Click on libraries tab 5. click on add external jar tab 6. choose jar file 7点击确定
Done.完毕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.