0

I am currently working on a project in Java where we have to use an avatar created by someone else. This avatar is a graphical executable. It communicates with the Java application through xmlrpc.

I want to be able to run (embed) this executable within my Java application. I don't just want to execute the executable, I want it to actually be visible within the Java application.

I know this behavior is possible in C# (Process class), so I was wondering: is this also possible in Java?

The avatar in the application must be scalable.

10
  • 1
    Are you aware that an executable might not be executable on some other system (e.g. Linux cannot easily execute Windows *.exe programs) and that it may be a security risk? Also, executables are not required to give some graphic. May 3, 2013 at 11:41
  • 1
    Well unless you have an emulator to run windows object code inside your java application, you do want Windows to run your executable. What do you mean by "being visible withing the java app." ? Do you want to get the output of the executable ? Take a look at Runtime.exec().
    – zakinster
    May 3, 2013 at 11:41
  • @BasileStarynkevitch at this moment I am not concerned with multi-platforms, for the moment I am developping it for windows. As for executables in general, I am talking about a specific executable (an avatar) that starts fullscreen.
    – bas
    May 3, 2013 at 11:43
  • 5
    It's sure not possible on OS X or *nix! If you only intend to support Windows, use C# & be done with it. May 3, 2013 at 11:47
  • 1
    @bas That's a nice trick but to do that you must use the Win32 API to build your interface, that's not possible in Java.
    – zakinster
    May 3, 2013 at 11:51

1 Answer 1

2

The C# example you gave uses a Win32 API trick that uses SetParent to change the parent of the running embedded executable's main window from the desktop window to a newly created control. In order to do that, you would need to :

  • Create a WinAPI Window control to contain your embedded executable
  • Have access to the Windows API to get a handle on the running .exe main window
  • Have access to the Windows API to use SetParent

The problem is that you don't have access to the Windows API in Java. And even using JNI or something like JNA that would'nt be easy to do so since you don't have direct access to the WinAPI Window control created by the JVM (except using some undocumented windows-specific Sun API).

1
  • thanks for the answer, I wasn't sure but I feared this.
    – bas
    May 3, 2013 at 17:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.