Using With Java 

Step 1 : Write the Java Code

Following is an snippet Java code for Recording, Saving the Recorded Macro in a file, and Playing the recorded macro.

public class TethysSDK{     

    public static native long StartRecording();

    public static native long StopRecording();

    public static native long SaveRecording (String FileName, String Password, long OverWrite, long CreateFolder);

    public static native long RegisterProduct (String UserName, String Key);

    public static native long RunMacro (String FileName, String Password, long StopOnEsc, String LogErrorFileName);

    static{

        System.loadLibrary ("VC_WKSPSDK");

    }

    public static void main (String [] args){

        long RetVal;

        String UName = "TrialUsername"; //Trial User Name

        String Key = "TrialKey";   // Trial Key

        // File Name where the Macros will be saved

        String FName = "c:\\MyWKSP.wksp";

        String Pass = "MyPassword"; //Password of the Macro.  

        //Application in which Macros will be recorded

        String pExeName = "Excel.exe";

        String pTitle = "";

        long StopEsc = 1;

        //Calling the RegisterProduct function to register the Product

        RetVal = RegisterProduct(UName,Key);

        if (RetVal == 0){

            System.out.println("Register Product Success");

        }

        else{

            System.out.println("Register Product Failed");                            

        }

        //Calling the Start Recording function.

        RetVal = StartRecording();

        if (RetVal == 0){

            System.out.println("Start Recording Success");

        }

        else{

            System.out.println("Start Recording Failed");

        }

        //Calling the StopRecording function.

        RetVal = StopRecording();

        if (RetVal == 0){

            System.out.println("Stop Recording Success");

        }

        else{

            System.out.println("Stop Recording Failed");

        }

        //Calling the SaveRecording function

        RetVal = SaveRecording(FName,Pass,0,0);

        if (RetVal == 0){

            System.out.println("Recorded File saved at location : " + FName );

        }

        else{

            System.out.println("Save Recording Failed");

        }

        //Calling the RunMacro function

        RetVal = RunMacro(FName,Pass,StopEsc,LogFileName);

        if (RetVal == 0){

            System.out.println("Run Macro Success");

        }

        else{

            System.out.println("Run Macro Failed");

        }

    }//Main method ends

}//Class Ends

Step 2: Compile the Java code

Command: javac TethysSDK.java 

Step 3: Make a header file of the java code.

Command: javah –jni TethysSDK.java

The above command will make a .h file in the current directory.  In this case TethysSDK.h.

Step 4 : Create a VC++ DLL, that calls the Tethys Macro SDK DLL (i.e. WKSPSDK.DLL)

Step 5: Copy jni.h, jni_md.h (Both these files are system files that comes with java) and WkspRecorder.h to the folder where the VC++ code exist.

Step 6: Compile the VC++ code.  It will create a DLL.

Step 7: Copy the VC++ DLL either to the System32 folder or to the folder where the java code exist.

Step 8: Compile the Java code

Command: javac TethysSDK.java

Step 9: Execute the Java Code.

Command: java TethysSDK