How to use Google Drive Api in Eclipse? - java

For the past few days I've been trying to upload and download files from Google Drive using Java. I've seen some tutorials on the internet but they all used Gradle and I need to do this in Eclipse. I can't use Gradle because it does not work with other parts of the project.
Does anyone know how to upload/download files in Google Drive using Java (Eclipse Neon)? Thanks.

You can also use Maven or just simply add the Drive client library to your project. Check out this page for Maven/download links:
https://developers.google.com/api-client-library/java/apis/drive/v2
Once you have the necessary jar in your project, you should be able to follow the existing tutorials on how to use Drive, e.g.:
https://developers.google.com/drive/v2/web/examples/

Related

Extract data from a MongoDB database using the Mongo Java Driver

I'm trying to write a program in Java that will connect to a MongoDB database. I already have the server, port, name, userDB, and username/password of the MongoDB database I'm trying to access.
I wasn't really sure where to start, so after looking around for a bit, I found a Java driver for MongoDB available on GitHub:
https://github.com/mongodb/mongo-java-driver. I downloaded the source code and imported it as a project on Eclipse. The source code for the driver has literally hundreds if not thousands of files. I tried running it as is, and couldn't get the project to compile.
I have no clue where to go from here. There isn't a lot of in-depth instructional material out there for this, and if I took the time to thoroughly inspect all the files in the driver, that could take decades.
You are on the right track here. What you need to do instead of downloading the source code is to download the JAR files or alternatively use Maven which is a dependency management tool.
This is what you will need to install the mongodb driver.
After you have successfully added the dependencies to your project. Use this quick start guide which will step you through the basics.
Here is an example of working with maven.
Don't get disheartened by small trials..there's always decades of documentation to read ;)
Download the .JAR file from here: https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver/3.0.0/
You need mongodb-driver-3.0.0.jar from this list.
Once you have that add it as a library dependency in your Eclipse project and you'll be all set.

OpenTok API for android

I am using OpenTokSamples project for OpenTok API and in that I want to create session id and token id through java code and I implemented the code by calling createSession() method but its throwing error----> Could not find class 'com.fasterxml.jackson.databind.ObjectMapper', referenced from method com.opentok.OpenTok.. I searched a lot and found need to add Jackson-databind jar & Jackson-annotations jar but still the issue is not getting resolved. Please help me on this.
There is another Jackson jar which implements the json<->object mappers.
This jar is jackson-mapper-XXX.jar [1]
If you check the repo [2], it comes with gradle support pointing to the dependencies it needs to build.
[1] http://repository.codehaus.org/org/codehaus/jackson/jackson-mapper-asl/
[2] https://github.com/opentok/Opentok-Java-SDK
You are meant to create sessions and tokens using the OpenTok Server SDKs, not on clients (such as Android).
It sounds like you are most familiar with Java as a language, so I suggest using the OpenTok Java SDK and running it on a server. There is a very easy to understand HelloWorld tutorial in the samples directory, with instructions on how to use it in the README.md file. It will guide you to get the server running locally on your development machine.
An even more useful example might the Learning OpenTok tutorial for Android. It shows how to send a request to a server that returns the session ID and token. The server used in this tutorial is written in PHP, but for your convenience there is a one-click button for starting your own server on Heroku (instead of locally on your development machine).
I hope this provides you all the information you need to start generating sessions and tokens dynamically! Let me know how that turns out, and feel free to give feedback on the tutorials as GitHub Issues in those repositories.

Creating and testing a jar with AndroidStudio

I want to create a jar file (there are no resources associated with it) using AndroidStudio that accesses our server APIs and will be used in several as yet unwritten Android apps. I also want to be able to test these APIs outside of an android app. It doesn't use any android libraries. My questions are 1) how do I configure gradle to just build a jar file? 2) What's the best way to exercise this code in AndroidStudio? Writing a small wrapper that includes a main function that imports the jar file? Writing a toy Android app that exercises the code? Or is my approach completely wrong?
If it doesn't use Android libraries, then why are you trying to create a .jar file in Android Studio? Just use ant. It's the same process as creating a .jar file for Volley, which is detailed in this SO question.

Can i use Coinbase API with dynamic web application without using Maven?

I'm new in Coinbase, but little confused. I get stuck every time with Coinbase API. Have a look at this API .. https://github.com/coinbase/coinbase-java
I want to make a project with this API using JSP. Where customer could play a role with Bitcoin. But If you see this API, it generally says to use Maven. But i don't know Maven. I've good handling at jsp and servlet. Simply i just know to create a project as "dynamic web project" into Eclipse.
So, Is it possible to use Coinbase API with dynamic web project without using Maven anymore. Please help.
Help, would be appreciated!
Yes, you can just download jar from maven repository http://mvnrepository.com/artifact/com.coinbase.api/coinbase-java/1.5.0 (and all its dependencies...). I highly recommend for you to learn what is maven (or gradle) and just use it to control your libraries. The best solution for now is to just install maven and git and follow the steps in Manual section on this page. It will produce for you ready to use jar lib which you can add to your project. The $YOUR_JAR_DIRECTORY change with folder where you want to build this lib.

Is it possible to host an Eclipse update site on Github?

I am using GitHub to develop an Eclipse plugin. I would like to have a public Eclipse update site for my plugin. Can I use GitHub for this?
I know that GitHub can be used for hosting individual files by using the "raw" links provided on the file information pages.
Forget the Github project releases feature, that won't work as a true update site (see notes at the end).
To achieve what you want, you can create a Github repo, commit/push your p2 repository there and then serve it as an update site, using raw links.
So for example, for the repository:
https://github.com/some-user/some-repository/
you can serve it as an update site using the link:
https://github.com/some-user/some-repository/raw/master/
Notes: Yes, if you open the update site link in a browser, github will give you no file listings, but rather a 404. But that's fine. The Eclipse update site mechanism doesn't need the parent link to be valid. Instead Eclipse will directly look for <update-site URL>/artifacts.jar (or .xml) and from the information in artifacts.jar, it will itself discover the URLs of the other artifacts stored in the update site. AFAIK, at no point does the Eclipse update mechanism need the web server to do file listings of a directory.
Note2: if you use Github project releases, you can only attach a zipped p2 repository to it. That is not a proper update site because it is a static repository: there is no URL to which new releases can be uploaded to. Eclipse won't be able to automatically discover new updates, rather the user will need to download the zip for each new release he/she wants to update to.
(Also with a proper update site, only the necessary artifacts for installation/update/query will be downloaded - a minor advantage)
Github pages are not a proper place for an update site.
Github pages may not properly serve large binary files as explained in this issue. It may be fine if your jars are small but overall they advise against placing binaries there. Instead they recommend placing binaries in the download section of the repository. I'd be happy if this situation changes because it would be very convenient to publish an update site by pushing to github.
For now one would have to use their API to programatically upload files in the download section. Answers to this other question points to some libraries and scripts that uses this API for use within java/maven, perl, ruby, etc.
You may now try it in a release page (July 2013).
See "Publish a project release (binary/source packages) on Github?"
Original answer (January 2013)
I have not tested it, but technically, a p2 repository can be defined in any shared path (either filesystem-shared or web-based-shared)
You should only need to:
generate the right p2 metadata
analyze the p2 repo in case of any issue.
store the all result in a git managed directory and push it to your GitHub repo.
http://pages.github.com/
The Github Pages feature allows you to host arbitrary folders of files without git turning each file into a github page.
I was able to host an Eclipse update site using the GitHub pages feature. I found it difficult to figure out all the pieces I needed, so here's a brief description of the steps I followed.
Build your Eclipse plug-in project, and test it on your local workstation.
Add a feature project, and add your plug in. Also set the description, copyright, and license information.
Configure a publishing source for your repository. I think the /docs folder is the easiest to work with. One way to generate a starting web site is to go to the GitHub repository settings page, and launch the automatic page generator.
Create an update site project nested inside the /docs folder. Put it in an obvious folder, like update.
Create a category, and add the feature to the update project.
Click the Build all button to generate the jar files.
Commit and push all the changes.
Try installing from the update site.
Once the update site works, you can publish your plug in in the Eclipse marketplace. This is optional, it just makes your plug in easier to find.
As others have mentioned, GitHub pages don't support huge binary files, so this will only work for small projects. To see an example, look at my Live Coding in Python project.
No it is not possible anymore, the Downloads API has officially been deprecated.
From the GitHub blog:
However, some projects need to host and distribute large binary files in addition to source archives. If this applies to you, we recommend using one of the many fantastic services that exist exactly for this purpose such as Amazon S3 / Amazon CloudFront or SourceForge. Check out our help article on distributing large binaries.
See this help article on distributing large binaries.
It turns out you absolutely can use GitHub Releases to host a p2 update site.
The main issue is that GitHub Releases hosts all files under a flat directory structure. Eclipse p2 repositories however, are hierarchical by default.
Since Eclipse Tycho (p2 actually), doesn’t allow you to configure a flat p2 repo structure, you need to script it.
The script needs to perform 2 things:
move every file under plugins/ and features/ to the root of the p2 repository,
replace all references to /plugins/ and /features/ with /, in the artifacts.xml file compressed in artifacts.jar and artifacts.xml.xz.
There are probably several ways to do it but in this blog post, you can see an implementation relying on a JBang script to achieve the desired goal:
https://fbricon.github.io/posts/use-github-releases-as-p2-repo/

Categories