2

I have a situation where I need to use javax.xml library and majority of this comes from Java 6. However my deployment server runs on Java 5, where I don't have control.

So is it possible to add these specific libraries to project and can run in Java 5 environment?

I am mainly using

import javax.xml.bind.*;
import javax.xml.stream.*;
import javax.xml.transform.stream.StreamSource;

code which I am using

    XMLInputFactory xif = XMLInputFactory.newFactory();
    StreamSource xml = new StreamSource("input.xml");
    XMLStreamReader xsr = xif.createXMLStreamReader(xml);
    while(xsr.hasNext()) {
        if(xsr.isStartElement() && xsr.getLocalName().equals("StandardError")) {
            break;
        }
        xsr.next();
    }

So can any one tell how can I avoid this so that My application can run in Java 5 environment without issues.

Between we use maven for building, so any libraries has to go into pom.xml

1
  • Doesn't that lot originate from JAXB? Commented Aug 26, 2012 at 10:36

1 Answer 1

2

JAXB (JSR-222) and StAX (JSR-173) were introduced in Java EE 5 and are completely compatible with Java SE 5 (The version of the JDK when those specs were released). Of course implementations of these standards were included as part of Java SE 6.

java.net Repository

You can obtain the public APIs for the standards from the java.net repository

    <repository>
        <id>java.net</id>
        <name>java.net Maven Repository</name>
        <url>https://maven-repository.dev.java.net/nonav/repository</url>
    </repository>

Below is the dependency for the latest version of the JAXB public APIs

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2</version>
    </dependency>

Implementations

In addition to the public APIs you will need to implementations. Each spec has multiple implementations. Below is a link to a POM file that pulls in EclipseLink MOXy as the JAXB implementation (Note: I'm the MOXy lead).

About Java SE 5

Java SE 5 hasn't received any public updates since October 2009, even Java SE 6 is rapidly approaching the end of life. If possible I would recommend using Java SE 7 (and Java SE 8 is currently in development).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.