To give a broad overview of how the Java-ECLiPSe Interface works, we take a closer look at QuickTest.java. Here is the Java source code from QuickTest.java.
import com.parctechnologies.eclipse.*; import java.io.*; public class QuickTest { public static void main(String[] args) throws Exception { // Create some default Eclipse options EclipseEngineOptions eclipseEngineOptions = new EclipseEngineOptions(); // Object representing the Eclipse engine EclipseEngine eclipse; // Connect the Eclipse's standard streams to the JVM's eclipseEngineOptions.setUseQueues(false); // Initialise Eclipse eclipse = EmbeddedEclipse.getInstance(eclipseEngineOptions); // Write a message eclipse.rpc("write(output, 'hello world'), flush(output)"); // Destroy the Eclipse engine ((EmbeddedEclipse) eclipse).destroy(); } }
The structure of the main method in QuickTest.java contains elements which will appear in any Java code which uses the Java-ECLiPSe interface. These are as follows:
EclipseConnection and its subinterface EclipseEngine are Java interfaces which contain the methods used when interacting with ECLiPSe.
We interact with the ECLiPSe engine by invoking methods on the object which implements EclipseConnection or EclipseEngine . In the case of QuickTest.java we invoke the rpc method, which causes the ECLiPSe to execute a goal, in this case one which simply prints a message.