The method outlined below, is outdated and discouraged, as it is rather complicated to implement.We have replaced it with one which involves packaging your java code as a Tersus plugin as outlined in http://www.tersus.com/#Id=7987.
This example is comprised of 2 parts:
MyJavaLib - an Eclipse Java Project with the source code for a library containing the classes to be used by the Tersus application.The library package is com.mycompany.mypackage containing the MyClass class, which contains a single method, sum, implementing a simple mathematical sum operation.To create a jar library using Eclipse, import the project into Eclipse (through File->Import...->General->Existing Projects into Workspace). Then build the project (in Eclipse this occurs automatically by default, or via Project > Build Project, then export it to a jar file via File > Export... > Java > JAR file - specify myjavalib.jar as the export destination.Note that the version of Eclipse bundled with Tersus is the Platform Binary version which does not contain the features required for building Java, you'll need to either download and install a separate Eclipse version (look for Eclipse for Java Developers) or use the the software update feature (Help > Install new software) to add the Eclipse Java Development Tools (JDT) to Tersus.If you'd rather use another Java development tool to build your library, it's also OK. Use the source code file - src/com/mycompany/mypackage/MyClass.java and build a jar containing it.Once you've prepared the .jar file, you'll need to copy it to the jars folder in the 2nd project (the Tersus project). Create the jars folder if it's missing.
MyTersusApp - a Tersus project demonstrating usage of myjavalib.jar.As noted above, the jar file can be found in the jars folder of the project.The model contains two number input fields, with <On Change> on either, calling the java method to compute their sum. The java call is performed via a server-side javascript call, as seen in the following screenshot:The javascript text is:var c=_env.instantiate('com.mycompany.mypackage.MyClass');Z=c.sum(X,Y);or in the generic case:var <dummyvar>=_env.instantiate('<package>.<class>');<exit>=<dummyvar>.<method>(<trigger1>[,<trigger2>[...[,triggern]]]);
To use the full functionality of this web site, JavaScript needs to be turned on.
For best results, use the Firefox browser..
Copyright © 2003-2017 - Tersus Software Ltd., All rights reserved. Terms of Use License Graphic design by EmaraDesign