rocky
rocky

Reputation: 435

Using google library in coldfusion without using Java library

Referring to the following library and my previous thread, I have two questions:

Question #1: I have decided not to mess up with Java Libraries and hence could anyone tell me if there is another way to figure out how to use the libphonenumber library in coldfusion?

Question #2: As discussed in my previous thread, that many people are porting it to different programming languages like JavaScript, Ruby, PHP as they are not written in Java. The google library libphonenumber is written in PHP and I am wondering why someone would port it to PHP language.

Upvotes: 0

Views: 172

Answers (1)

Leigh
Leigh

Reputation: 28873

(This is more of a comment, but is a little too long)

Seems like this was already answered in the comments of your other thread, but to reiterate:

Is there another way to use a java library from CF?

No. There is basically only one way to use java libraries from CF. Add the jar(s) to the class path and use createObject. You could also use a dynamic class loader like Mark Mandel's JavaLoader.cfc (or the rip of that project baked into CF10+). However, ultimately they all do the same thing.

Since using java libraries is pretty simple in CF, I am curious why you do not want to use it. While I suppose you could rewrite it in pure CFML, I would ask why? The whole point of libraries is reuse, which saves development time. Since there already is a compatible library available to you, there is not much point in rewriting it. Not unless you are doing it as a learning exercise.

The google library libphonenumber is written in PHP

No. There is port that is written in PHP. The "official" project is "a Java, C++ and Javascript library.". So it sounds like your options are the java version (server side) or javascript version (client side use). That is it.

I am wondering why someone would port it to PHP language.

Because the java library is not compatible with every platform out there, PHP being one of them. If a developer on an unsupported platform wanted to use it, they have two choices: port it or write their own from scratch. Since the google project already did most of the heavy lifting, porting is simpler.

Upvotes: 1

Related Questions