This will use GE's SetCameraParams function to make the camera fly to a small island off the coast of Madagascar. My initial goal was to make a basic Google Earth Java API by wrapping some of the COM API -- but since I didn't really have a need for it, the project never really lifted off. -- So I thought rather than just letting the bit of code rot away in a dusty corner of my HD I might share and see if any young java developer thinks interfacing with GE is fun.

To run the program you just have to add the jacob.jar to your classpath. And of course you must have Google Earth installed. The program will launch GE and fly to the location (which you can interrupt at any time with the mouse).

Replies To: Google Earth COM API

Re: Google Earth COM API

Posted 03 July 2010 - 09:03 AM

I wanted to capture a question that came to me VIA PM:

The Last Fighter, on 03 July 2010 - 07:16 AM, said:

Hello NickDMax

I need your help in something relating communicating java with Google earth.
But I do not want to be involved in importing libraries or so, just I want to open the Google Earth by java using system calls, then sending commands and arguments to it by cmd using system calls, too.

Have you any idea how to do so ?

Thanks for your time.

My reply:

Quote

I have only worked with Google Earth though the old COM API which requires an interface library (I used JACOB in my code)

One easy way to integrate with GE is to embed a browser and then use the GE plug-in and its Javascript API. That *should* work from java (I know many phone apps do it this way).

And this, "I do not want to be involved in importing libraries" -- look to do some interesting integrations with various programs you will often either need a library, or write your own. Java exists in the VM and it is VERY limited in what it can do with interacting with other applications (because it is isolated intentionally) -- if you want to interact with a program you will probably need a C/C++ interface, you can either write that for yourself in JNI, OR you can use a library - it is up to you, but I generally choose a library.

Re: Google Earth COM API

Posted 03 July 2010 - 03:36 PM

Ok, I tried to import the library as you said, and I ran the program, but I got errors in running. That I think was because the class id of Google earth on my pc is surely different from yours, so my question is how can I know mine? (sorry for any stupid questions, but I am quiet new to those topics)

This post has been edited by The Last Fighter: 03 July 2010 - 03:36 PM

Navigate to where you places your jacob.jar (for me this was C:\JavaExtras\Jacob-1.15-M3\ ) and select jacob.jar

Expand jacob.jar in the tree and select "Native Library location" and click "Edit" and set this to the jacob directory (should contain some .dll files)

you can also take a moment to add in the Javadocs for the library (I always find this helpful).

Now right click on your project and select "build path > configure build path" and goto the "libraries" tab and click "Add library", select "user library" and press next, select the Jacob library you just created and press "Finish"

Re: Google Earth COM API

Posted 05 July 2010 - 05:06 AM

Now it works !! I discovered the source of the error , and it was that I had to copy the dll files in windows directory

Thanks very much

But I still have question,
1-How do you know the new class id of google earth if it is changed ?
2-Does the same method used here works also with any other program?
If yes, how I can know the class id of this program ?
3-I knew the source of the problem, but I still do not understand what happened when I transferred the dll to windows folder

Re: Google Earth COM API

Posted 06 July 2010 - 09:00 AM

hi NickDMax,
thanks for pointing me here.
now since reading with select statement works perfectly well; writing params into system objects like into w32UserAccount doesnt.
I tried it with invoke(method, str, obj)
with setProps() and call()...but no success.
maybe you can help me here, any idea?