简体   繁体   中英

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

and have downloaded the latest versions of eclipse EE and JDK (x32 for windows)

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

And have created a java project, set the JRE to the jdk7 and changed the compiler compliance level to 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?

Thanks,

javax.json is not part of the standard Java EE installation. You need to find the jar file and add it to your classpath. The jar file can be found at https://java.net/projects/jsonp/downloads/directory/ri or if you're using 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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