Finding the Remaining Days/Hours of a Trial License

Declare Variables/Constants

String FEATURE_NAME = "FeatureTrial";
String FEATURE_VERSION = "1.0";
String CONTACT_SERVER = "localhost";

String ScopeFeatureInfo=new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
   "<sentinelScope>"+
     "<feature index=\"0\">"+
       "<name>"+FEATURE_NAME+"</name>"+
       "<version>"+FEATURE_VERSION+"</version>"+
     "</feature>"+
    	"</sentinelScope>");


Attribute attrAppContext = null;
ApplicationContext appContext = null;

API Calls

To check the remaining days/hours for a trial license, execute the APIs in the specified sequential order only:

>attrAppContext = new Attribute();

>attrAppContext.set(LicensingConstants.SNTL_ATTR_APPCONTEXT_CONTACT_SERVER, CONTACT_SERVER);

NOTE   If instead the LSFORCEHOST or LSHOST environment variables are set, then the above-mentioned steps are not required.

>appContext = new ApplicationContext(attrAppContext);

>String featureInfo = appContext.getInfo(ScopeFeatureInfo, LicensingConstants. SNTL_QUERY_FEATURE_INFO_VERSION("1.0"));

If the appContext.getInfo call is successful, the featureInfo string contains an XML-based output having the detailed information.

Parse this XML, the "trialDaysLeft" and the "trialSecondsLeft" tags in this XML contains the remaining number of trial days and trial hours (in seconds), respectively.

NOTE   The trial usage information is refreshed while requesting, updating or releasing a trial license.