missing JSON libraries for Google App Engine application? - java

I recently purchased a copy of Practical Android Projects. Chapter 8 talks about how to use Google App Engine with Android. It gives as an example (source code available here in the folders PracticalAndroidProjectsSourceCode/Projects/08_GameManager and 08_GameService) an Android application which consumes a web service from an App Engine application.
I haven't been able to get the example App Engine application (which provides the service) to run correctly. The problem is that the application expects JSON libraries which aren't available. I've tried downloading JSON libraries from elsewhere on the web as JAR files and including them in the application. (See discussion.) This hasn't worked, because none of the JSON libraries I've tried seem to be fully compatible with the libraries it's expecting.
I'm new to Android and GAE development, and as such these problems are daunting to me; I've spent days trying to find a solution. Anybody want to take a crack at this problem? If I do find a solution, I will post it here so anybody else who purchased the book will be able to run this example!
Are you able to run this example on your machine? I'm using Eclipse as my IDE.

I don't know that book and you didn't show the exact code you tried, but the name of the JSON library varies depending on which runtime version (in app.yaml) you use. For Python (== Python 2.5), use simplejson. For Python 2.7, use plain json. The following example straightens out the differences for the rest of your code:
try:
import json
except ImportError:
inport simplejson as json
Now in the rest of your code you can always use json.dumps() and json.loads().

You should include a JAVA JSON library in your web project under under WEB-INF/lib.
Have a look to these libraries:
Jackson
GSON

Related

Proper maven dependency for my stable python library from github into main java web app build

I have a Vaadin Java web app build in eclipse. I also have a python library managed separately which I now integrate into my java web app. This works using a folder for python code within my web app code.
Now: I want to properly manage my python code separately from my github with versions and want to build the Java web app including a specific version of this python code (i.e. stable release) to continue working on the python code toward the next stable release without interference with the web app (just standard version control of a main app and a separate library I control and develop).
My experience so far is to include third-party dependencies for my Java web app but none are my own. I now want to use this same method for my own separate libraries.
Q: What is the proper way to express a Maven dependency in my Java Web app build with my Python code sitting on Github so that I do not need to manually include the python code within my web app repo?
If this has been answered, please point me to the best post, many thanks!
EDIT:
Following the comments received, it looks like my assumption to use Maven for solving the separate versioning of a set of files in my Java app is not the way to go. I am therefore opting to make my Java app project depend on the Python project in Eclipse where I can ensure to checkout only the stable version of the Python files to affect the Java build accordingly.
If this makes sense, we can close this question, many thanks for the comments and assistance.

How can I use the Google Calendar API in Java EE in Netbeans

I am currently working on a piece of university coursework where we are building a website using Java EE and Glassfish. We need to do some scheduling using a calendar API. We are not allowed to use any Java frameworks, everything we do must be done in JavaScript, which means that Gradle and Maven are a no go.
What I have tried so far:
I have created a project in Google's Developer site and have obtained by Client ID and Secret
I have downloaded the .jar files to use with our application from here.
I have read through the README file and have imported the .jar files needed for both Java Core and Java Servlets
When I try and import the necessary package (import com.google.api.services.calendar.Calendar;), I get a warning in Netbeans saying that the package does not exist.
Please can someone help me with this issue,
Thanks in advance.

I've added a Jar to my IDE classpath on Codename One and now my cloud builds fail

I added a JAR for JSON parsing to my NetBeans classpath when building my application. Everything worked great in the simulator but I got a build error from the build servers as I try to build the native app.
How can I parse JSON or use arbitrary JAR's in Codename One?
Codename One has builtin support for JSON in the JSONParser class.
However, the bigger question at hand is changing the classpath which Codename One doesn't allow since the native JAR might not work on the mobile device. This is explained in this post which is a bit old but the basic reasoning is:
An arbitrary JAR might use an API that isn't supported by Codename One.
An arbitrary JAR might be compiled with a compiler that generates bytecodes that are untested with the build servers (e.g. in the past Eclipse ADT had some issues with the old VM).
Codename One's build process doesn't know the JAR is there and doesn't send it to the servers.
The most common case is using native libraries and JAR's don't have builtin support for native code on mobile devices.
To solve these issues Codename One has a cn1lib file format and a list of available cn1lib libraries. You use them by placing a cn1lib in the lib directory and pressing "Refresh Libs" in the context menu.
cn1libs support native code, hints on code completion and will work for native builds "as is". Steve did a thorough tutorial on porting the native iOS/Android Freshdesk SDK to Codename One here.

java android openlayers equivalent

I am looking for a java library that can display map from different sources.
I saw a similar posts like
(Java equivalent of OpenLayers).
but i am not so sure how its interact with the android interface.
also i need it to support a single picture source (no tiles lib)
similar to http://jsfiddle.net/rdt2/N7dSu/37/.
basically i need something that support image source an Google Maps source
is anyone familiar with such a thing?
If you don't like to run the app in a browser you can always fall back and deploy the OpenLayers browser application via PhoneGap to a native Android app.
http://phonegap.com/

Google API in Java application without a web server

I am working on a small Java Swing based application, and want to add a decorative feature in it to sync files with Google Drive. But, all the documentation / discussions about Google API's that I see talks about putting this code into a web application. Also, the credentials of the client on https://cloud.google.com/console require the origin URL, without which the API will not work.
I know I can either embed a Jetty or take the hard way of sending and receiving HTTP requests. But either would be an overkill for this petty application that I am making. So, I was wondering if there is a way to include a Jar file that just lets me login and then access the folders on the Google drive.
Do you know of one? Is this possible with the existing API's? Thanks for your help!
If you have a look at the detailed installation instructions then there is a section for general purpose java applications. That is your case.
The following are the jars from the dependencies folder required for general purpose Java 5 applications (or a newer compatible version of each dependency):
google-api-client-1.17.0-rc.jar
google-oauth-client-1.17.0-rc.jar
google-http-client-1.17.0-rc.jar
commons-logging-1.1.1.jar
gson-2.1.jar httpclient-4.0.3.jar
httpcore-4.0.1.jar
jackson-core-2.1.3.jar
jsr305-1.3.9.jar
protobuf-java-2.2.0.jar
xpp3-1.1.4c.jar
You can use the GooglePromptReceiver to ask the end user to paste the authorization code from the browser to your application. You can find examples in the samples. The cmdline samples apply to your case.

Categories