java 尽管类路径中有 jar 文件,但包 javax.ejb 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12875479/
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-10-31 10:36:39  来源:igfitidea点击:

package javax.ejb does not exist inspite of jar file in classpath

javacompilationejbjavac

提问by Asif Shiraz

I'm trying to compile a java program using command

我正在尝试使用命令编译一个 java 程序

javac -d build src/*.java -verbose

It returns me the following:

它返回给我以下信息:

src\Currency.java:5: package javax.ejb does not exist
import javax.ejb.*;
^
src\Currency.java:7: cannot find symbol
symbol: class EJBObject
public interface Currency extends EJBObject {
                              ^ 

I'm using jdk1.6.0_35. CLASSPATH contains C:\wls1036_dev\modules\ which contains javax.ejb.jar

我正在使用 jdk1.6.0_35。CLASSPATH 包含 C:\wls1036_dev\modules\,其中包含 javax.ejb.jar

What could possibly be the problem?

可能是什么问题?

回答by rockstar

I faced the same problem .

我遇到了同样的问题。

You need to add javaee5.jarto you class path .

您需要添加javaee5.jar到您的类路径。

For example I imported an ejb project and then realised I was using a version of Netbeans that did not have the EJB & EAR support . So i downloaded the plugin . After doing that the javaee5.jar was present at C:\Users\sjauhar\AppData\Roaming\NetBeans\7.3.1\modules\ext . Added it to my project and the error went away .

例如,我导入了一个 ejb 项目,然后意识到我使用的是没有 EJB 和 EAR 支持的 Netbeans 版本。所以我下载了插件。这样做之后, javaee5.jar 出现在 C:\Users\sjauhar\AppData\Roaming\NetBeans\7.3.1\modules\ext 。将它添加到我的项目中,错误消失了。

回答by GreyBeardedGeek

The classpath must contain the full path to each jar file you want included, not just the folder in which your jar files exist. So, for example, add

类路径必须包含要包含的每个 jar 文件的完整路径,而不仅仅是 jar 文件所在的文件夹。因此,例如,添加

C:\wls1036_dev\modules\javax.ejb.jar

C:\wls1036_dev\modules\javax.ejb.jar

to your classpath

到你的类路径

回答by Pradeep Pati

You should ideally compile using the JDK provided by WebLogic, rather than using the J2SE bin and libs.

理想情况下,您应该使用 WebLogic 提供的 JDK 进行编译,而不是使用 J2SE bin 和 libs。