What dependencies do I need on Gradle?

Asked

Viewed 76 times

1

What are the necessary dependencies for the following libraries?

import java.io.StringReader;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

1 answer

2


javax.xml.parsers

The package javax.xml.parsers matches JAXP and can be found in jaxp-api-1.4.5.jar. For Gradle, you’d use this:

compile group: 'javax.xml.parsers', name: 'jaxp-api', version: '1.4.5'

It is also distributed in the standard library. In Java 9 it is in module java.xml.

javax.xml.soap

The package javax.xml.soap corresponds to SAAJ and can be found in saaj-api-1.3.5.jar. For Gradle, you’d use this:

compile group: 'javax.xml.soap', name: 'saaj-api', version: '1.3.5'

It is also distributed in the standard library. In Java 9 it is in module java.xml.ws, but how this module is marked with @Deprecated(since="9", forRemoval=true), then it is better to import it as a library in Gradle than to use the standard Java 9 module. This does not mean that SAAJ has been discontinued or abandoned, it just means that it will no longer be distributed as part of the JDK after Java 9, should then be added as an external dependency (exactly what Gradle does).

java.net, java.io and java.util

The packages java.net, java.io and java.util are in the standard library. In Java 9, all of them are in the module java.base. So you don’t have to do anything special at Gradle to use them.

org.w3c.dom and org.xml.sax

The packages org.w3c.dom and org.xml.sax are also in the standard library. In Java 9, they are in the module java.xml.

  • Libraries downloaded correctly, and now what? :runErro: Could not find or load the main class Loadwebservice FAILED FAILURE: Build failed with an Exception. * What Went Wrong: Execution failed for task ':run'. > Process 'command 'C: Program Files Java jdk1.8.0_162 bin java.exe'' finished with non-zero Exit value 1

  • @Eduardoweise That from there appears to be another different mistake, I think (I’m not sure) that means he didn’t find the class LoadWebService which would be the main class (the one with the public static void main(String[] args)). I recommend that you post another question and put the full code of your Gradle configuration file in it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.