在另一个项目Eclipse中调用一个类 [英] calling a class in another project Eclipse

查看:399
本文介绍了在另一个项目Eclipse中调用一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目A,我需要从另一个项目B调用一个类c。



我已经完成了以下工作。点击A - >属性 - >构建路径 - >,并在Java源的一个选项卡中选择项目B. - >接受



现在我可以创建类c的对象,但是当我运行项目时,我得到ClassNotFoundException



更新



我不断得到java.lang.ClassNotFoundException。



在JSF - >属性 - >构建路径 - >项目--->我添加了项目:





在运行中 - >运行配置 - > ClassPath我有:





现在我已经添加了项目JIRA和JIRA依赖关系



JIRA项目有这样的依赖关系:





我收到以下错误:





但这个类是在M2_REPO中:





解决方案



仅在没有Maven的JAR中添加JIRA依赖项:

,现在它运行了。

解决方案

您需要将项目B添加到项目A使用的运行配置中。在菜单运行 - >运行配置...中,将项目B添加到运行配置的classpath 。


I have a project "A" and I need to call a class "c" from another project "B".

I have done the following. Click in "A" -->Properties -->Build Path --> and in one tab of Java Source I selected the project B. --> Accept

Now I can create objets of Class "c" but when I run the project I get "ClassNotFoundException"

Update,

I keep getting java.lang.ClassNotFoundException.

In "JSF" -->Properties -->Build Path --> Projects ---> I Added the Project:

In Run --> Run Configurations --> ClassPath I had:

and now I have added the project "JIRA" and "JIRA dependencies"

JIRA project has this dependencies:

And I get the following error:

but this class is in M2_REPO:

SOLUTION

I add "JIRA dependencies" only in JARs without Maven: and now it´s run.

解决方案

You need to add project B to the Run configuration used by project A. In the menu Run -> Run configurations... , add the project B in the tab 'classpath' of your run configuration.

这篇关于在另一个项目Eclipse中调用一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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