Page 1 of 1

Java API in standalone CLI?

Posted: Tue Feb 21, 2017 4:40 pm
by Undertone
Hi,

I am looking at the samples, to use the Java API, and all I am seeing is samples running inside a Web App where Servlet Instance is needed in

Code: Select all

engine.getDeviceForRequest("some UA String");
Is it possible to run the Java API in pure command line way?

Re: Java API in standalone CLI?

Posted: Tue Feb 21, 2017 4:45 pm
by aaronp
Hi Ravneet,

As far as I know, that is the only way to use the Java API. However, I will reach out to my engineering team to see if they know of a way to run the API through the command line and check back in with you as soon as I have an update.

Thanks,

Aaron

Re: Java API in standalone CLI?

Posted: Tue Feb 21, 2017 4:54 pm
by Undertone
Thanks Aaron. I have a use case where having a Java standalone application (not a web app) might need to use the API to resolve capabilities on a User Agent string passed manually to the API (not from a Servlet request).

Re: Java API in standalone CLI?

Posted: Tue Feb 21, 2017 5:04 pm
by aaronp
Hi Ravneet,

Thank you for the information. I'm not sure if you have seen this already but the following documentation contains sample code which may be of interest to you. Instead of taking in live requests, you can run your detection by passing user agent strings through STDIN.

Code: Select all

        Device device = wurfl.getDeviceForRequest(user_agent);
        System.out.println("Is Tablet: " + device.getCapability('is_tablet'));
https://docs.scientiamobile.com/documen ... e-java-api

Let me know if this helps!

Thanks,

Aaron

Re: Java API in standalone CLI?

Posted: Tue Feb 21, 2017 6:05 pm
by Undertone
HI Aaron,

Thanks! I am good to go with the sample now. I was not adding the right jar (Servlet APIs for example) as that has a dependency even if you are trying to build a command line app.

I am able to run the sample that I wrote now.

Thanks
Ravneet