> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrade from Java Legacy to v4.8.0 or Latest Version

> Migrate from legacy Java SDK to v4.8.0+ — code changes required

## Introduction

This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.

<Warning>
  <strong>Deprecation notice:</strong> We’re deprecating Plivo Java SDK legacy versions lower than v4.8.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
</Warning>

## Migrate your applications

### Java version support

The Plivo Java SDK supports OpenJDK 8 and 11 and OracleJDK 8 and 11.

Use the command `Update-Package Plivo -Version 4.10.0` to upgrade to the active version of the SDK, or upgrade to the latest version.

After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.

### Import the SDK

<CodeGroup>
  ```java Legacy theme={null}
  import com.plivo.helper.api.client.*;
  import com.plivo.helper.xml.elements.Dial;
  ```

  ```java Latest theme={null}
  import com.plivo.api.Plivo;
  import com.plivo.api.xml.Dial;
  ```
</CodeGroup>

### Initialize

<CodeGroup>
  ```java Legacy theme={null}
  RestAPI api = new RestAPI("<auth_id>","<auth_token>", "v1");
  ```

  ```java Latest theme={null}
  Plivo.init("<auth_id>","<auth_token>");
  ```
</CodeGroup>

### Accessing resources

<CodeGroup>
  ```java Legacy theme={null}
  Call resp = api.makeCall(parameters);
  ```

  ```java Latest theme={null}
  CallCreateResponse response = Call.creator(parameters)
                  .create();
  ```
</CodeGroup>

### Make a call

<CodeGroup>
  ```java Legacy theme={null}
  package com.plivo.test;

  import java.lang.reflect.Field;
  import java.lang.reflect.Modifier;
  import java.util.LinkedHashMap;
  import com.plivo.helper.api.client.*;
  import com.plivo.helper.api.response.call.Call;
  import com.plivo.helper.exception.PlivoException;

  public class App {
      public static void main(String[] args) throws IllegalAccessException {
          String auth_id = "<auth_id>";
          String auth_token = "<auth_token>";
          RestAPI api = new RestAPI(auth_id, auth_token, "v1");

          LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
          parameters.put("to","2025552323"); 
          parameters.put("from","2025551212"); 
          parameters.put("answer_url","https://s3.amazonaws.com/static.plivo.com/answer.xml");
          parameters.put("answer_method","GET"); 
          try {
              Call resp = api.makeCall(parameters);
              System.out.println(resp);
          } catch (PlivoException e) {
              System.out.println(e.getLocalizedMessage());
          }
      }
  }
  ```

  ```java Latest theme={null}
  using System;
  using System.Collections.Generic;
  using Plivo;
  package com.plivo.api.samples.call;

  import java.io.IOException;
  import java.util.Collections;

  import com.plivo.api.Plivo;
  import com.plivo.api.exceptions.PlivoRestException;
  import com.plivo.api.models.call.Call;
  import com.plivo.api.models.call.CallCreateResponse;

  class CallCreate {
      public static void main(String [] args) {
          Plivo.init("<auth_id>","<auth_token>");
          try {
              CallCreateResponse response = Call.creator("+12025551212", Collections.singletonList("+12025552323"), "https://s3.amazonaws.com/static.plivo.com/answer.xml")
                  .answerMethod("GET")
                  .create();
              System.out.println(response);
          } catch (PlivoRestException | IOException e) {
              e.printStackTrace();
          }
      }
  }
  ```
</CodeGroup>

### Dial XML

<CodeGroup>
  ```java Legacy theme={null}
  import java.io.IOException;

  import com.plivo.helper.exception.PlivoException;
  import com.plivo.helper.xml.elements.Number;
  import com.plivo.helper.xml.elements.Dial;
  import com.plivo.helper.xml.elements.PlivoResponse;

  class CustomCallerTone {
     public static void main(String[] args) throws PlivoXmlException {
         PlivoResponse response = new PlivoResponse();
         Dial dial = new Dial();
         dial.setDialMusic("https://<yourdomain>.com/dial_music/");
         Number number = new Number("12025552323");
        

         response.append(dial);
         dial.append(number);
         System.out.println(response.toXML());
         resp.addHeader("Content-Type", "text/xml");
         resp.getWriter().print(response.toXML());;
     }
  }
  ```

  ```java Latest theme={null}
  package com.plivo.api.xml.samples.dial;

  import com.plivo.api.exceptions.PlivoXmlException;
  import com.plivo.api.xml.Dial;
  import com.plivo.api.xml.Number;
  import com.plivo.api.xml.Response;

  class CustomCallerTone {
      public static void main(String[] args) throws PlivoXmlException {
          Response response = new Response()
                  .children(
                          new Dial()
                                  .dialMusic("https://<yourdomain>.com/dial_music/")
                                  .children(
                                          new Number("12025552323")
                                  )
                  );
          System.out.println(response.toXmlString());
      }
  }
  ```
</CodeGroup>

### Conference XML

<CodeGroup>
  ```java Legacy theme={null}
  import java.io.IOException;

  import com.plivo.helper.exception.PlivoException;
  import com.plivo.helper.xml.elements.Conference;
  import com.plivo.helper.xml.elements.PlivoResponse;

  class ModeratedConference {
     public static void main(String[] args) throws PlivoException {
         PlivoResponse response = new PlivoResponse();
         Conference conference = new Conference("My Room");
         conference.setEnterSound("");
         conference.setStartConferenceOnEnter(true);
         conference.setEndConferenceOnExit(true);
         conference.setWaitSound("https://<yourdomain>.com/music/");
         response.append(conference);
         System.out.println(response.toXML());
         resp.addHeader("Content-Type", "text/xml");
         resp.getWriter().print(response.toXML());;
     }
  }
  ```

  ```java Latest theme={null}
  package com.plivo.api.xml.samples.conference;

  import com.plivo.api.exceptions.PlivoXmlException;
  import com.plivo.api.xml.Conference;
  import com.plivo.api.xml.Response;
  import com.plivo.api.xml.Speak;

  class ModeratedConference {
      public static void main(String[] args) throws PlivoXmlException {
          Response response = new Response()
                  .children(
                          new Speak("You will now be placed into a demo conference"),
                          new Conference("demo")
                                  .endConferenceOnExit(true)
                                  .startConferenceOnEnter(false)
                                  .waitSound("https://<yourdomain>.com/waitmusic/")
                  );
          System.out.println(response.toXmlString());
      }
  }
  ```
</CodeGroup>

### Record API

<CodeGroup>
  ```java Legacy theme={null}
  package plivoexample;

  import java.io.IOException;
  import java.util.LinkedHashMap;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import com.plivo.helper.api.client.RestAPI;
  import com.plivo.helper.api.response.response.Record;
  import com.plivo.helper.exception.PlivoException;

  class recordApiAction {
     public static void main(String[] args) throws PlivoException {
         String auth_id = "<auth_id>";
         String auth_token = "<auth_token>";
         RestAPI api = new RestAPI(auth_Id, auth_Token, "v1");
         LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
         parameters.put("call_uuid",call_uuid);
         Record record = api.record(parameters);
         System.out.println(record);
        
     }
  }
  ```

  ```java Latest theme={null}
  package com.plivo.api.samples.call.record;

  import java.io.IOException;
  import com.plivo.api.Plivo;
  import com.plivo.api.exceptions.PlivoRestException;
  import com.plivo.api.models.call.Call;
  import com.plivo.api.models.call.actions.CallRecordCreateResponse;

  class RecordCreate {
      public static void main(String [] args) {
          Plivo.init("<auth_id>","<auth_token>");
          try {
              CallRecordCreateResponse response = Call.recorder("eba53b9e-8fbd-45c1-9444-696d2172fbc8")
                  .record();

              System.out.println(response);
          } catch (PlivoRestException | IOException e) {
              e.printStackTrace();
          }
      }
  }
  ```
</CodeGroup>

### Record XML

<CodeGroup>
  ```java Legacy theme={null}
  import java.io.IOException;

  import com.plivo.helper.exception.PlivoException;
  import com.plivo.helper.xml.elements.Record;
  import com.plivo.helper.xml.elements.Dial;
  import com.plivo.helper.xml.elements.Number;
  import com.plivo.helper.xml.elements.PlivoResponse;

  class recordSession {
     public static void main(String[] args) throws PlivoException {
         response.append(record);
         response.append(dial);
         dial.append(number);
         System.out.println(response.toXML());
         resp.addHeader("Content-Type", "text/xml");
         resp.getWriter().print(response.toXML());;
     }
  }
  ```

  ```java Latest theme={null}
  package com.plivo.api.xml.samples.record;

  import com.plivo.api.exceptions.PlivoXmlException;
  import com.plivo.api.xml.Dial;
  import com.plivo.api.xml.Number;
  import com.plivo.api.xml.Record;
  import com.plivo.api.xml.Response;

  class RecordACompleteCallSession {
      public static void main(String[] args) throws PlivoXmlException {
          Response response = new Response()
                  .children(
                          new Record("https://<yourdomain>.com/get_recording/")
                                  .redirect(false)
                                  .startOnDialAnswer(true),
                          new Dial()
                                  .children(
                                          new Number("12025552323")
                                  )
                  );
          System.out.println(response.toXmlString());
      }
  }
  ```
</CodeGroup>
