why different packages or naming conventions in google cloud? - java

I have recently started using google cloud platform and came across various packages like
Storage storage = storageBilder.build();
storage.get("bucketname", Storage.BucketGetOption.fields())
Storage.BucketGetOption.fields();
If I use the code above i am facing The method get(String, Storage.BucketGetOption) is undefined for the type Storage.
It actually using the storage from below packages
com.google.api.services.storage.Storage storage = storageBilder.build();
(i.still.do.not.know.this.)storage.get("bucketname", Storage.BucketGetOption.fields())
com.google.cloud.storage.Storage.BucketGetOption.fields();
why this storage is implemented in various ways? what is the difference or use of com.google.api and com.google.cloud?
Could anybody please explain?

Google has released a number of Java API client libraries over the years.
The current, best Java API client is the google-cloud library. It uses the Java packages com.google.cloud. For Cloud Storage, you're using this library if the classes are under com.google.cloud.storage.
Before this library, there was another set of libraries called the Google APIs Client Libraries. These libraries put their classes in the com.google.api package. For Cloud Storage, you'd find classes in com.google.api.services.storage. Code that uses this library will also use a distinctive storage-resource-verb function pattern, like storage.buckets().objects().get() pattern.
The Google APIs Client Libraries are still supported, but I recommend preferring the google-cloud libraries for new code. Unfortunately, because of this library switch-over, some code examples you'll find online will use the former or the latter or, worse, both.

Related

Java Library in Android Project

I want to make a java library (so I can compile it into a jar) that makes calls to a server. I then want to share this amongst android application projects so that I can access those simple calls.
Is using HTTPRequest the best way to do this?
http://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html
Something about making web calls in the java way and sharing them in android apps seems odd to me. should this be an Android Library instead? (I believe those should only be used when resources are involved)
Sorry for the potentially simple question.
You can develop a common Java library that you can use with both android , and regular java projects.
Take a look at OkHttp , it shows you how to achieve this. It is related to HTTP client, may be it already provides everything you need. You can extend it where needed.
For a simpler example (~20 java classes), take look at Okio , the underlying io library used by OkHttp.

Android Apps using python

I found that Android development can be done through Python from the link http://www.linuxplanet.com/linuxplanet/tutorials/7157/1. My question is whether all the libraries that are available in Java are also available in python.
Any of you already started with python on Android if so please indicate links to help get our group up to speed.
No, not all the libraries have been exposed. You can look at the SL4A project on google-code for more information regarding the support it has.
Is this a complete API bridge, or are there restrictions?
BeanShell, JRuby, and Rhino basically give you a complete API bridge (you can invoke Java calls directly). See the documentation for those interpreters for instruction on how to accomplish this. Cross compiled languages like Lua are more restricted. They only have access to the APIs exposed through the RPC layer. See the API reference for a list of currently supported APIs. The RPC layer is easy to extend.

How to get the tags from an Amazon AWS EC2 instance with java library

I have been using Typica as my java library of choice for interfacing with my EC2 and EBS instances. AWS recently added tags to their API, but it seems that Typica has not updated to support the tags ability inside their ImageDescription object.
Has anyone used a 3rd party library in java for interfacing with the tags API in EC2? Is there any alternatives (other than rolling it myself) that I'm missing?
To use the latest features you'd better use Amazon AWS SDK for Java, their original library.
After you get used to, is not that bad, and you can also wrap it with your classes to make it behave the way you like.

Has Oracle removed Sun net.ftp classes?

I have an older project that uses the sun.net.ftp.FtpClient class to download a file from an ftp server. It appears that Oracle has finally removed this unsupported/deprecated feature from Java. Any suggestions on what should be used to replace it? I was considering org.apache classes but I have never used them. The best solution would be the simplest.
Dependending on your requirements i'd recommend to use either the FTP client provided by Apache Commons Net or edtFTP/j.
finj - FTP Client for Java Apps
What is finj ?
Sun provides
a FTP client written in Java as part of the standard classes.
Unfortunately, since the sun.net.ftp.* classes are not
part of the java.* packages, neither the source code
nor a complete API are available.
The goal of this project is to provide to developers a complete,
well designed, programmatically controllable Open-Source
FTP client written in the Java language. finj then simply stands for 'FTP in Java'.
It provides an API similar to sun.net.ftp.FtpClient so that you can use it without changing your code very much.

DLL/TLB in Java<->DCOM communication

I have to write an OpenOffice add-on (in Java) which communicates with DCOM server of some closed-source application. The major problem is that, I don't have any documentation about server's Interfaces .
All I have is a VB/C++ SDK kit for the Application. SDK contain a library in dll and a bunch of *.tlb files. In SDK documentation there is an information, I can use java, but there is no example at all. I have read provided examples and it looks like all the communication wit DCOM goes through this dll.
Is there a way to somehow import such dll/tlb functions def directly to java, bypass dll and comunicate with DCOM or I have to write a C++ wrapper(dll)? What is the best way to do it?
Any hints are welcomed.
You can use a project like j-Interop for communication with (D)COM servers.

Categories