Java API in standalone CLI?

Undertone
Posts: 5
Joined: Thu May 30, 2013 10:13 am

Java API in standalone CLI?

Postby Undertone » Tue Feb 21, 2017 4:40 pm

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?

aaronp
Posts: 228
Joined: Wed Dec 09, 2015 12:39 pm

Re: Java API in standalone CLI?

Postby aaronp » Tue Feb 21, 2017 4:45 pm

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

Undertone
Posts: 5
Joined: Thu May 30, 2013 10:13 am

Re: Java API in standalone CLI?

Postby Undertone » Tue Feb 21, 2017 4:54 pm

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).

aaronp
Posts: 228
Joined: Wed Dec 09, 2015 12:39 pm

Re: Java API in standalone CLI?

Postby aaronp » Tue Feb 21, 2017 5:04 pm

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

Undertone
Posts: 5
Joined: Thu May 30, 2013 10:13 am

Re: Java API in standalone CLI?

Postby Undertone » Tue Feb 21, 2017 6:05 pm

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


Who is online

Users browsing this forum: No registered users and 2 guests