Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embedding native applications in Java

Status
Not open for further replies.

Diancecht

Programmer
Jan 8, 2004
4,042
0
0
ES
Hi. I know this is a quite strange requirement, as it's against cross-platform issues, eficiency and even logic, but I'm curious about this.

I'm looking for a way to embed Windows native graphical applications like, for example, notepad, in a Java GUI as Java windows.

What I want is to get Java containers that can be called from the GUI just to open and close, and the contexts of them to be native applications, independent from the JVM.

I've got it for IE by using some particular interfaces it has, but does anyone knows a way to do it with a genereic Win32 window?

Thank you.

Dian
 
You can always call external application (exe for windows).
Only thing you have to know is its path!
 
Thank you for the reply, but by doing that the applications would run externally like another OS program.

What I want to do is emebed them inside my Java application.

Cheers,

Dian
 
You should be able to use the Java's native language support to call main .... At least in theory. I've never tried it. What do you mean "emebed"?

I think the best you'll be able to do is to launch them (even if you are able to call main from JAVA as opposed to having the OS do it...
 
Sorry, was a typo, I meant embeded.

There's no problem launching any kind of application. The problem arises with the graphical part. Imagine you have an application launcher ina JFrame and you want that, on user click, a native application gets displayed inside the Java window.

That can be done through Canvas and some JNI work. The problem is you need to be able to instantiate the native graphic container and add it to the Java one.

Cheers.

Dian
 
So have the windows application be a window in an MDI? I'm thinking that isn't possible, as the only native function you know each native application has is a main or an APImain... I think you'd have to do some pretty fancy poking... You might be be able to use them as OLE objects (like when Word uses Excel or other product) -- but I don't know if even that would work or not.
 
Well, as I said before, I did it for IE, so it's possible. The key is that you don't need to know what the program is doing, it's just a Canvas for you. To instantiate it, you can do it as an OLE control, as you said.

For example, IE is based in the WebWrobserControl interface.

I was looking for a common interface for more applications, so I could instantiate the via a native API, but it seems that each application has its own OLE Control, so no kind of generic work can be done.

Cheers,

Dian
 
When you did it with IE, you were using the COM interface provided by IE (in other words, IE was acting like an ActiveX control). This is supported because IE was written to allow it. But you aren't "embedding" it -- IE is still being run off the users machine, and not from your PC. If you find a computer without IE, you'll see that it doesn't work anymore.

At the same time, you can't embed any arbitrary executable in your program -- they're Win32 executables, and Java runs in it's JVM. The two use fundamentally different approaches to program development. Only by using an external communication method (like COM or causing another process to start) can this possibly work.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
OK, let's give some background on this issue.

chiph, you're rigth, I used a COM interface. But IE runs locally on the same machine as the JVM.

What is this for? Well, I have a Java (J2SE) environment for end-users. Inside it there is a wide variety of applications from different environments running embedded (remote applications, transactional access, workflow, ...)

What I did was to give access to a JSEE server by embeding a browser in the Java application, IE for Windows, working on FireFox for Linux.

If it's possible for IE, why not for Word or Excel? In fact, Word plugin for IE just instantiates a COM interface and embeds it into the browser.

If course the external program runs "externally", but you can exchange data via a native interface. In fact, I communicate J2SE and JSEE servers with this tecniques.

I know that not all applications follow the same design pattern, but all of them have common functionalities, at least at OS level. What I was wondering is if any of that interfaces is suitable to be embeded on a Canvas to be presented as a part of a Java UI.

At the moment I don't have much time, so I had to take a look at other things, but I will go back to it.

Cheers,

Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top