简体   繁体   English

如何在Eclipse中为Java EE7设置导入

[英]How to setup imports in Eclipse for Java EE7

I would like to follow this tutorial: 我想遵循本教程:

http://docs.oracle.com/javaee/7/tutorial/doc/jsonp003.htm#BABHAHIA http://docs.oracle.com/javaee/7/tutorial/doc/jsonp003.htm#BABHAHIA

and have downloaded the latest versions of eclipse EE and JDK (x32 for windows) 并已下载最新版本的eclipse EE和JDK(适用于Windows的x32)

http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplersr2 http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplersr2

http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-7-sdk-with-jdk-u45-2066865.html http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-7-sdk-with-jdk-u45-2066865.html

And have created a java project, set the JRE to the jdk7 and changed the compiler compliance level to 1.7 并创建了一个Java项目,将JRE设置为jdk7,并将编译器的遵从级别更改为1.7。

but as soon as I try to use something like: 但是一旦我尝试使用类似的东西:

import javax.json.Json;

I encounter an error with it being unable to be resolved by eclipse - where can I configure eclipse such that it accepts these imports? 我遇到一个无法通过eclipse解决的错误-在哪里可以配置eclipse使其接受这些导入?

Thanks, 谢谢,

javax.json is not part of the standard Java EE installation. javax.json不属于标准Java EE安装的一部分。 You need to find the jar file and add it to your classpath. 您需要找到jar文件并将其添加到您的类路径中。 The jar file can be found at https://java.net/projects/jsonp/downloads/directory/ri or if you're using Maven 可以在https://java.net/projects/jsonp/downloads/directory/ri上找到jar文件,或者如果您使用的是Maven

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.0</version>
</dependency>

I am experiencing this exact issue. 我遇到了这个确切的问题。 I am using JDK 7u67. 我正在使用JDK 7u67。 Eclipse does not recognize javax.json, even though Oracle (the previous link: docs.oracle.com/javaee/7/tutorial/doc/jsonp002.htm#BABDFHHD) indicates that these classes are part of 7. Eclipse无法识别javax.json,即使Oracle(先前的链接:docs.oracle.com/javaee/7/tutorial/doc/jsonp002.htm#BABDFHHD)表明这些类是7的一部分。

I've been unable to find an answer. 我一直找不到答案。 I did grab the .jar and put it in jre/lib/ext and eclipse was happy after a restart. 我确实抓住了.jar并将其放在jre / lib / ext中,重新启动后eclipse很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM