IE automation sample
import com.jniwrapper.win32.automation.Automation; import com.jniwrapper.win32.automation.OleContainer; import com.jniwrapper.win32.automation.IDispatch; import com.jniwrapper.win32.automation.types.Variant; import com.jniwrapper.win32.ole.types.OleVerbs; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * This example demonstrates the embedding of Browser component into Java. */ public class IEAutomationSample extends JFrame { private OleContainer container = new OleContainer(); public IEAutomationSample() throws HeadlessException { super("Internet Explorer "); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(container); container.createObject("Shell.Explorer"); // Create Browser component by its ProgID final Automation webBrowserAutomation = new Automation(container.getOleObject()); webBrowserAutomation.invoke("Navigate2", new Object[]{"www.teamdev.com"}); Variant documentVariant = webBrowserAutomation.getProperty("Document"); IDispatch document = documentVariant.getPdispVal(); System.out.println("document = " + document.isNull()); this.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { // Show browser component, when parent widnow is shown container.doVerb(OleVerbs.SHOW); } public void windowClosing(WindowEvent e) { // Destroy the object when window is closed container.destroyObject(); } }); } public static void main(String[] args) throws Exception { final IEAutomationSample sample = new IEAutomationSample(); sample.setSize(800, 600); sample.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sample.setLocationRelativeTo(null); sample.setVisible(true); } }
COM interfaces & data types wrappers allow working with COM types and interfaces like ordinary Java
objects. For example, you can use IUnknown
, IClassFactory
, and
IDispatch
as typical Java interfaces, and
Variant
(VARIANT), BStr
(BSTR), SafeArray
etc. as regular Java
types.
ComfyJ allows invoking methods of a COM object via its function indexes in VTBL (Virtual Method Table), or by its names using the Automation approach. Also, Automation allows for obtaining and setting properties of a COM object, including indexed and named ones.
ComfyJ provides a set of different concurrency models which you can use for initializing COM integration in your Java application.
ComfyJ allows you to create a COM object on a remote server.
All COM and other native resources will be garbage-collected automatically, or you can release them if required by the application logic.
ComfyJ includes the OleContainer
Swing component, which allows you to:
ProgID
, CLSID
, or from a document file.
Also, you can insert a COM object (which implements IOleObject
COM interface) into
container.
OleObject
to or from a file in a special binary format.ComfyJ provides a standard COM technique for creating and advising COM event handlers to a COM object.
With this bundled application, you can generate Java COM wrappers for COM components or COM Type Libraries. These generated classes allow you to work with COM objects just like regular Java objects. Moreover, this application can compile the generated classes and pack them into a JAR file, if needed.
This aspect of ComfyJ allows you to create Java COM servers purely in Java. In other words, a designed Java COM server can be exposed as COM objects to other COM applications without writing a line of a native code.
To simplify creation of custom Java COM servers, ComfyJ provides the base classes such as IUnknownServer
and IDispatchServer
so any custom Java COM objects can inherit these classes, depending on
application requirements. Such Java COM servers can implement as many COM interfaces as required—from
standard COM interfaces and COM interfaces generated by ComfyJ's Code Generator application, to custom
ones.
ComfyJ also provides convenient ways for registering created Java COM servers. Such registration can be performed at runtime, i.e., for COM event handlers, or in COM Registry using a bundled ServerManager application. Also, you have the ability to register Java COM servers at runtime without using the ServerManager application. Such registered Java COM servers can be used by other COM applications.
Run the demo comfyjdemo.jnlp
Runs on Microsoft Windows XP or later with:
During evaluation period please use the email address, provided to you in the evaluation email.
If you have an active support subscription, please use the email address, provided to you in the email confirming the license purchase.
You can ask a question on our product forum. In order to do it, you will need a Google ID.
links.teamdev.com/comfyj-forum
Send email: comfyj-forum@teamdev.com
Your message will be automatically posted on the web.
Evaluation SupportProvided for 30 days |
Standard SupportProvided for one year with 25% discount for renewal |
Premium SupportContract-based time and materials service |
---|---|---|
Help with the product use | Help with the product use | Help with the product use |
Response within one business day | Response within one business day | Response within one business day |
Provided by email | Provided by email | Provided by email |
— | Product updates | Product updates |
— | — | Phone, chat and remote desktop |
— | — | Feature development |
— | — | Priority issue resolution |
Evaluate for Free | Request Renewal | Request Premium |
If you have questions, not covered by the documentation, please email us at sales@teamdev.com.
License use is governed by the product license agreement
The prices on this page are exclusive of any taxes.
It is possible only if that .NET component is built with enabled COM interop.
This property instructs ComfyJ's NativeResourceCollector (NRC) whether to release the COM object automatically or not. By default, this property is set to true for all resources that implement AutoDeleteParameter
interface. When this property is set to false, the .release()
method should not be called.
A required COM interface can be queried using the IUnknown.queryInterface() method, for
example:
IOleObjectImpl oleObject = new IOleObjectImpl(); comObject.queryInterface(oleObject.getIID(), oleObject);
IOleObjectImpl oleObject = new IOleObjectImpl(comObject);
Yes, ComfyJ can be used in Java applets. There are several examples in ComfyJ distribution archive, in its samples\Applets\src\ subfolder, which demonstrate using of ComfyJ in Java applets.
Yes, every COM object can be released using its IUnknown#release() method. Make sure to set its AutoDelete property to false before releasing the object.
Yes, ComfyJ provides OleContainer Java component that allows embedding of any ActiveX component.
The simplest way is to package these files to the \META-INF\ subdirectory of an application JAR file.
The simplest way is to package all required JNIWrapper library files to root folder of an application JAR file.
0x800401F0; CO_E_NOTINITIALIZED
COM should be initialized using ComFunctions.coInitialize()
method in each Java thread (except OleMessageLoop) before working with COM objects.
Yes, ComfyJ provides the ability to create Java COM servers and register them in COM.
Take a look at the license installation instruction.
Our licensing is based on versions of ComfyJ. Having purchased the license for our product you get the right to use the current major version of the product.
Major and minor version upgrades issued during your active Standard Support subscription period are free of charge. Upon expiration of the Standard Support subscription you can renew it with a 25% discount from the actual license price.
Please take a look at the Product License Agreement.
You only need to purchase 2 licenses. We license our library by the number of people who write code using our library.
This is possible with the Per Developer License.
You can distribute unlimited number of copies of your product with our library enclosed.
You may want to purchase a Project License, which is cost-effective in case there are 3 and more developers on the team. The Project License is bound to a single project you do, but it allows any number of developers in your company to work with our library.
Project License is bound to your project via a fully-qualified class name. A fully-qualified name for a class is the package name followed by the class name, separated by a period (.). For example: com.mycompany.myproduct.MyClass
This can be any class of your application. The only requirement is that it should be included into your Java application class path.
When we say “project” we have in mind one product of your company including your future product versions or potential derivative works based on your product.
The Project License is tied to one project only.
The best solution would be to purchase the Company–wide License, which covers any number developers and projects in one company.
Upon the license purchase you will receive an archive with two types of license files: development and runtime. Development licenses are intended to be used in the development process. Runtime licenses are to be used for distribution of your software with ComfyJ enclosed.
Yes, you can purchase ComfyJ Source Code License; it is provided on a per developer basis. Please contact our sales team if you are interested in this option.
We will email you your trial key and a quick