EZ Jcom "Calling Java" Tutorial: Step oneThis tutorial covers calling Java from the following languages:
The EZ JCom installation includes a Java JAR file
C:\EZJcom\sample\CallingJavaTut.jarfor use in this tutorial. This JAR file contains a very small number of Java classes and interfaces containing very simple methods, that show the concepts for using EZ JCom to call Java from other languages. The first step of the tutorial is to gain brief familiarity with the contents of this JAR file.
The Java classes and interfaces provided in this JAR file are briefly described below. This tutorial assumes that the reader may not know Java, therefore if you do know Java you may find some information superficial!
tutorial.CallingJavaTutThis Java class provides
tutorial.ReverseStringThis is a Java interface. It has one method reverse that reverses a string. It does not contain an implementation of reverse as it is an interface. As mentioned above, the tutorial.CallingJavaTut class contains an implementation of reverse.
tutorial.CallingJava2This class extends the class tutorial.CallingJavaTut. Extending a class in Java means that wherever an argument of type tutorial.CallingJavaTut is expected, tutorial.CallingJava2 may be substituted. Also, this class automatically gets the methods and fields of CallingJavaTut. It provides two additional methods:
tutorial.OnTimerIn Java, events are handled via interfaces. The tutorial.OnTimer interface handles timer events. It contains only one method onTime which takes a date and time value as argument.
tutorial.CastingTutThis class contains various methods that show how to handle Java "casting" in EZ JCom.
tutorial.UITutThis class extends a Swing JPanel and builds a simple user interface including checkboxes, radio-boxes, and a JButton. In addition to a constructor, this class has a method to register a listener for the JButton button-clicks. For this Java class, EZ JCom can optionally generate a visual control that can be embedded in C#, VB6 or VB.NET forms.
tutorial.OnClickAn interface for listening to button-click events in tutorial.UITut objects.
Now we will proceed to buiding a COM (ActiveX) wrapper for these Java classes, so the methods can be called from other languages.