如何在 Eclipse 中包含 javax.jms.*?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9809891/
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
how to include javax.jms.* in eclipse?
提问by Galaxin
Iam trying to implement JMS using eclipse.But when I tried to save the code, it showed that javax.jms.* cannot be resolved
and there are no suggestions
as well recommended by it.
我正在尝试使用 eclipse 实现 JMS。但是当我尝试保存代码时,它显示了这一点,javax.jms.* cannot be resolved
并且还有no suggestions
它推荐的。
How can I include it and use it? when I googled I found that javax.jms.* is not a part of java API,then how can I use it in eclipse and get my program run successfully?
我怎样才能包含它并使用它?当我用谷歌搜索时,我发现 javax.jms.* 不是 java API 的一部分,那么我如何在 eclipse 中使用它并使我的程序成功运行?
I would like to implement JMS with the help of activemq
,what all do I need to download and include in code?
我想implement JMS with the help of activemq
,我需要下载什么并将其包含在代码中?
Iam a newbie to this JMS, please suggest some references or sample code that can implement JMS using activemq.
我是这个 JMS 的新手,请推荐一些可以使用 activemq 实现 JMS 的参考或示例代码。
采纳答案by Vikram
When you download the activemq archive file from Internet. Extract this archive: /apache-activemq-x.x.x
当您从 Internet 下载 activemq 存档文件时。提取此存档:/apache-activemq-xxx
cd into this apache... directory.
cd 进入这个 apache... 目录。
You will see activemq-all-x.x.x jar file.
您将看到 activemq-all-xxx jar 文件。
Include this in your build path.
将此包含在您的构建路径中。
This should resolve your issue.
这应该可以解决您的问题。
回答by Andreas
There are actually many ways to fix this. As already stated in the comment you need the Java Enterprise Edition API. Java EE is an abstract specification so what you need is an implementation of the JMS API. Since JMS is part of the Java EE specification the easiest thing is to download a application server such as GlassFish (which is the reference implementation) or JBoss.
其实有很多方法可以解决这个问题。正如评论中所述,您需要 Java Enterprise Edition API。Java EE 是一个抽象规范,因此您需要的是 JMS API 的实现。由于 JMS 是 Java EE 规范的一部分,最简单的方法是下载应用程序服务器,例如 GlassFish(参考实现)或 JBoss。
I assume you already got the Java compiler so you only need the SDK, not the JDK.
我假设你已经有了 Java 编译器,所以你只需要 SDK,而不是 JDK。
Java EE 6 SDK Update 4 A free integrated development kit used to build, test, and deploy Java EE 6 applications.
Java EE 6 SDK Update 4 一个免费的集成开发工具包,用于构建、测试和部署 Java EE 6 应用程序。
http://www.oracle.com/technetwork/java/javaee/downloads/index.html
http://www.oracle.com/technetwork/java/javaee/downloads/index.html
Then after you have downloaded GlassFish you will end up with a lot of files that is an implementation of the different Java EE specification API's. You will probably want to download the plugin that I linked to beneath so that you can start, deploy and do many other administration task of your server from Eclipse. I do not use Eclipse so I don't remember if you want this version of Eclipseas well.
然后,在您下载 GlassFish 之后,您最终会得到许多文件,这些文件是不同 Java EE 规范 API 的实现。您可能希望下载我在下面链接的插件,以便您可以从 Eclipse 启动、部署和执行服务器的许多其他管理任务。我不使用 Eclipse,所以我不记得你是否也想要这个版本的Eclipse。
http://marketplace.eclipse.org/node/867
http://marketplace.eclipse.org/node/867
At last you want to add GlassFish to your buildpath.
最后,您想将 GlassFish 添加到您的构建路径中。
I found this blog post (Scroll to "Create projects in Eclipse") if you are unsure what to add, but there are several blog posts on how to add GlassFish to the build path in Eclipse so I won't list them here.
如果您不确定要添加什么,我找到了这篇博文(滚动到“在 Eclipse 中创建项目”),但有几篇博文介绍了如何将 GlassFish 添加到 Eclipse 中的构建路径,因此我不会在此处列出它们。
http://www.webagesolutions.com/knowledgebase/javakb/jkb005/index.html
http://www.webagesolutions.com/knowledgebase/javakb/jkb005/index.html
回答by Brandon Heck
In addition to the answers already provided, if you are using Maven you can add the following dependency (available from Maven2 Central repo):
除了已经提供的答案之外,如果您使用的是 Maven,则可以添加以下依赖项(可从 Maven2 Central repo 获得):
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</dependency>
回答by Will
It can be found in jboss-jms-api.jar
它可以在 jboss-jms-api.jar 中找到
回答by mithun kanchi
If it is a maven project, add the following dependency to your pom.xml and it should start working as expected.
如果它是一个 maven 项目,请将以下依赖项添加到您的 pom.xml 中,它应该会按预期开始工作。
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
</dependency>
回答by Pranav
When you have downloaded activemq zip file from http://activemq.apache.orgthen when you extract it, head on to .jar file of activemq(This jar file is required). Now from Eclipse do as follows:
当你从http://activemq.apache.org下载了 activemq zip 文件然后当你解压它时,转到 activemq 的 .jar 文件(这个 jar 文件是必需的)。现在从 Eclipse 执行以下操作:
- RightClick on Project and go to Properties
- Java Build Path tab
- Libraries tab
- Add External JARs...
- Get that .jar file from activemq folder
- 右键单击项目并转到属性
- Java 构建路径选项卡
- 库选项卡
- 添加外部 JAR...
- 从 activemq 文件夹中获取该 .jar 文件
回答by rahulnikhare
If you are using/Testing ActiveMQ. Then configure your build path and add external jar activemq-all-.jar. (Path:In ) Clean and Build. This will helped me , will do same to you as well.
如果您正在使用/测试 ActiveMQ。然后配置您的构建路径并添加外部 jar activemq-all-.jar。(路径:在)清理和构建。这会帮助我,也会对你做同样的事情。
Danke,
Rahul.
回答by Māris Rubenis
If you want to resolve this issue using maven, then the correct maven dependency, available in maven repository, is the following:
如果您想使用 maven 解决此问题,那么 maven 存储库中可用的正确 maven 依赖项如下:
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms-api</artifactId>
<version>1.1-rev-1</version>
</dependency>
See post: The following artifacts could not be resolved: javax.jms:jms:jar:1.1
回答by Haftom Alemayehu
I fixed this problem by including the dependency of Activemq.
我通过包含 Activemq 的依赖项解决了这个问题。
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.0</version>
</dependency>