Is there a way to display a Flash or Adobe Reader ActiveX control in a Java AWT frame?
I'm porting a large old J++ application to standard Java and it needs to host a certain ActiveX control on an AWT frame.
Is this possible?
I looked at the JACOB (Java to COM Bridge) project and it doesn't appear to support ActiveX objects that draw on the screen.
It looks like this can be done by mixing AWT and SWT.
The Eclipse project has a sample snippet that embeds Microsoft Word into an AWT/SWT mixed app.
It appears that you will need to purchase a proprietary library in order to able to do this, as Java itself doesn't allow access to COM. Another similar question (about just Flash in Java) can be found here and a couple commercial solutions were listed.
I should note that whatever route you end up taking, you should optimally try to find a library that provides access to an Internet Explorer control, as opposed to just Flash or Adobe Reader. That's because, once you have access to an IE element, you can provide it with a URL (even if it's a local file) of either a .swf or .pdf document, and it will automatically load the correct plugin for each (I used this shortcut once for a personal C++ project in which I needed to load several different ActiveX controls). It appears that the EasyJCom library at the above link does provide such access to an embedded IE control.
Related
I'm using IntelliJ IDEA, I have coded a frame which I want to put into an HTML file so I can run it in my browser, how do I do this now that I cannot use JApplet? I have found this documentation: http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html and this http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html but I am new to programming and find this difficult to follow. I don't know for instance how I would go about putting my class files and the image that I used in a separate directory nor do I know how I go about signing my application so that it will run in a browser.
I want to put into an HTML file so I can run it in my browser,
You can use the Desktop class. This class allows you to access default applications from your desktop.
Read the section from the Swing tutorial o How to Integrate With the Desktop class for more information and working examples.
See Java Plugin support deprecated and Moving to a Plugin-Free Web.
Note that is one of my 'copy/paste comments' that does not explicitly mention JFrame based apps., however the links are still relevant in that Oracle & browser makers would not be phasing out support for applets if they wanted programmers to keep trying to shove rich client apps (e.g. Swing GUIs) into thin client web pages.
OTOH you can offer a JFrame (or a JApplet) to be launched from a link in a web page to end up free floating on the desktop of the user by using Java Web Start.
Even then, it is not a simple matter for the programmer or the end user. The programmer needs to ensure the app is digitally signed using a code signing certificate issued by a CA (usually they are expensive). The end user used to just be able to click the link, 'OK' the prompts produced by the Java virtual machine, and see the app appear on-screen. But now most browsers will download the launch file to the local file system rather than directly hand it to the JVM to be launched. So the user faces an extra step in explicitly finding the downloaded launch file and double clicking it.
This is all due to security concerns related to bugs in the plug-ins that run things in web pages. So if you were to find a way around all these hoops, please let us know. It is a security bug that requires urgent fixing.
is JavaFX capable of loading and embedding OCX Controls? I would like to use the Internet explorer in my Application, because the WebKit browser lacks support for ActiveX. And since I have to rely on third party ActiveX Controls (I know they are evil), I am bound to the IE.
This question is not purely related to "Can I use OCX in Java" because I would like to have some kind of component for JavaFX I would like to use.
Or do I have to rely on libraries posted here:
Use a .OCX Control in Java
Thanks in advance,
Sven
You have to rely on the libraries posted in the link you supplied in your question.
Or you need to write your own JNI interface.
If you do access OCX components, you may need to place them in their own window rather than sharing a window created by a JavaFX stage as you may run into issues with the JavaFX renderer conflicting writes on the window portions in which the OCX components are displayed - you would have to try it and see what happens to confirm.
The easier way to do this may be to request that users of your application set their default browser to IE, and then call the JavaFX hostservices.showDocument(uri) api to launch an IE page which embeds the OCX components you need.
Another alternative is to:
Embed your JavaFX application as an applet in a web page.
Also embed your activex controls in the web page.
On display of the web page, check the browser and, if it isn't IE, tell they user that the must be using Internet Explorer.
Have the user accept any miscellaneous security warnings the Browser displays.
Have the user (or perhaps JavaScript) resize the browser window to fullscreen (see IE9 Full Screen Mode or Full Screen Browsers with JavaScript).
Communicate between your active X controls and java app using javascript invoked via calls from the javafx/javascript bridge and control your active X controls via VBScript embedded in the page.
It would probably work, but it is such an ugly Frankenstein solution . . .
If you can convert your media to a format which JavaFX supports and just play it back direct through JavaFX, that would be much preferable, or it may also turn out that due to a deep ActiveX integration requirement that JavaFX is not the best solution to your problem and you could be better off with something like Silverlight.
I need a integrated or embedded java browser. I used WebEngine of javafx which support basic css as well html & java script but could not able to run flash file. Any way to do so.
Or any other Project u know which could fulfill my requirement.
You can also look at JxBrowser Java library that allows embedding Chromium-based web browser control into Java AWT/Swing application.
It supports both Java Swing and JavaFX.
BTW: the browser control is totally lightweight. All rendering happens in a separate native process by native Chromium engine. The web page looks like it's displayed in Google Chrome.
Check those (although they are not JavaFX but I suppose that they can be used):
http://lobobrowser.org/java-browser.jsp - pure Java
http://www.javadesktop.org/articles/jdic/index.html - better imho, but no longer maintained
I know this can be a bit of weird question, but let me explain the idea behind it first.
I have a win32 app exposed a an Activex host, this gives me the the following useful features:
Embed and call it from Internet Explorer as a simple to pass/return values from it using javascript.
Embed and call it from any win32 application made in languages like visual basic, c++, delphi etc. Even i can call it from MS office products like excel and word.
I have been asked to migrate this app to Java SWT but i donĀ“t know if it can be done without losing the mentioned capabilites, the only way could be to expose the app itself as an Activex host, can this be possible?.
Thanks a lot.
I have no experience with ActiveX, but a lot of examples are in snippets folder at SWT homepage. Try to check them..
If you migrate your app to Java SWT then you will lose the desired functionality of using in IE and as well as in other MS product based on COM or ActivX technology. Although one crude way could be to use some bi-directional COM broker like Jacob.
If given a choice then I will utilize the SWT's in-built support for COM and will try to embed your activex component in my swt application. For example, you can look at:
org.eclipse.swt.browser.IE -- Allows access to IE ActiveX component in the form SWT browser control.
org.eclipse.compare.internal.win32.WordComparison this is a part of eclipse's file diff plugin. The class is very nicely written and gives a COM flavored snippet of diffing two MS word files.
In this way I can have the activex intact for whatever purposes.
There is this article on adding activex support to swt without using any third party COM bridge
What's out there that lets you do this? Are there any OSS projects or maybe something a little more popular than this: http://www.jpackages.com/jflashplayer/ ? This does exactly what I'm suggesting (i.e. cuts out the need for Swing UI for the most part) but for a number of reasons I'd be interested in any better alternatives. Are there any? Any alternatives would need to support the Flex SDK.
Use the SWT GUI toolkit, which has an embedded browser. You can even deploy you own webkit with it, and let flash run in this browser, so you are platform independent, and don't rely on native browsers.
It will however be a large deployment, because of the browsers size.
EDIT: You can also emed the Flash ActiveX control directly in an SWT composite (Composite is the JPanel of SWT)
JavaFX 2 has a web control. I can't remember if the beta can do flash yet or if still upcoming. But if it doesn't support flash yet then it probably will soon, they release updates every 2 or so weeks to test.
You could also try the JFlashPlayer from DJ Native Swing: http://djproject.sourceforge.net/ns
It is essentially the SWT Browser, but with all sorts of integration headaches solved, and proper API.