How to connect REST API with certificate in Java using GET and read message

I have never used REST API, but have to get data using it, I have jks cerificate and connection URL. How can I used it with GET Method. tried with Google available code but failing with certificate related error. Please help.

Code -- Not working

package com.barclays.ods.utils;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;

public class ODSRouteCheckUtility {


  public static void main(String[] args) throws Exception {

    String odsGlossUrl = "https://testurl/df-web/Query" ; //args[0];
    ODSRouteCheckUtility odsRouteCheckUtility = new ODSRouteCheckUtility();
    odsRouteCheckUtility.MyGETRequest(odsGlossUrl);
      MyGETRequest(odsGlossUrl);

  }

  public static void MyGETRequest(String odsGlossUrl) throws IOException {
    URL urlForGetRequest = new URL(odsGlossUrl);
    String readLine = null;
    HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
    conection.setRequestMethod("GET");
    int responseCode = conection.getResponseCode();


    if (responseCode == HttpURLConnection.HTTP_OK) {
      BufferedReader in = new BufferedReader(
              new InputStreamReader(conection.getInputStream()));
      StringBuffer response = new StringBuffer();
      while ((readLine = in .readLine()) != null) {
        response.append(readLine);
      } in .close();
      // print result
      System.out.println("JSON String Result " + response.toString());
      //GetAndPost.POSTRequest(response.toString());
    } else {
      System.out.println("GET NOT WORKED");
    }
  }

  private static void readFromStream(InputStream response) throws Exception {
    try (BufferedReader br = new BufferedReader(new InputStreamReader(response))) {
      String strCurrentLine;
      while ((strCurrentLine = br.readLine()) != null) {
        System.out.println(strCurrentLine);
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
  }
}

Error : Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed at sun.security.ssl.Alert.createSSLException(Alert.java:131) at sun.security.ssl.TransportContext.fatal(TransportContext.java:353) at sun.security.ssl.TransportContext.fatal(TransportContext.java:296) at sun.security.ssl.TransportContext.fatal(TransportContext.java:291) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:652) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:471) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:367)

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum