How to resolve javax.xml.bind.JAXBContext in Eclip

2019-02-26 08:35发布

In my android app I use:

import javax.xml.bind.JAXBContext;

But I get:

The import javax.xml.bind cannot be resolved

I do have "com.viewstreet.java.eclipse.jaxbplugin.JAXBPlugin" in my plugins list...

4条回答
混吃等死
2楼-- · 2019-02-26 08:59

download jax-b.jar and add it as external jar in your project.

查看更多
萌系小妹纸
3楼-- · 2019-02-26 09:02

Put the JAR in the project's libs/ directory, then add it to the build path via the Add JARs button. That's my standard recipe, and it seems to work, and it has the advantage of putting the JAR in the right spot for command-line builds as well.

At this point, though, I suspect that you will get a compile error. Generally, you cannot import classes in the java and javax packages into an Android project.

查看更多
Lonely孤独者°
4楼-- · 2019-02-26 09:18

Any import cannot be resolved in Java means a class you referenced is not found anywhere on the classpath. You need the library you're trying to use added to your classpath. In Eclipse, that's in project properties in the Java Build Path => Libraries tab. If you don't have the jar file that contains the API you're trying to use, you probably need to get it from http://jaxb.java.net/.

查看更多
登录 后发表回答