Friday, December 18, 2015

use of large java math library from javascript


I came across GWT when I was looking for a way to use a large java math library on the client with javascript. GWT may be targeted as building web apps from the ground up using java rather than porting large existing java libraries but from what I see there have been such ports nonetheless.

The library is called SRM and makes a lot of classes and methods available which can be used to compute sophisticated and well defined 3d coordinate transformations.

Here is a typical example of how it would be used in a small application.

import SRM.*;

public class CdToCcConv
    public static void main (String args[])
        System.out.println("*** Sample program using SRM Java API to convert a 3D coordinate");
        System.out.println("*** from a Celestiodetic SRF to a Celestiocentric SRF.");

        // Declare reference variables for the CD_3D and CC_3D SRFs
        SRF_Celestiodetic CdSrf = null;
        SRF_Celestiocentric CcSrf = null;

            // Create a Celestiodetic SRF with WGS 1984 and Identity transformation
            CdSrf = new SRF_Celestiodetic(SRM_ORM_Code.ORMCOD_WGS_1984,

            // Create a Celestiocentric SRF with WGS 1984 and Identity transformation
            CcSrf = new SRF_Celestiocentric(SRM_ORM_Code.ORMCOD_WGS_1984,

            // Create a 3D Celestiodetic coordinate with
            // longitude           => 10.0 degrees (note: this input parameter is converted to radians)
            // latitude            => 20.0 degrees (note: this input parameter is converted to radians)
            // ellipsoidal height => 100.0 meters
            Coord3D_Celestiodetic CdCoord =

            // Instantiate a 3D Celestiocentric coordinate
            // This is an alternative method for instantiate a 3D coordinate
            Coord3D_Celestiocentric CcCoord = new Coord3D_Celestiocentric(CcSrf);

            // print out the SRF parameter values and the coordinate component values
            System.out.println("CdSrf parameter =>  \n" + CdSrf);
            System.out.println("CcSrf parameter =>  \n" + CcSrf);
            System.out.println("CdCoord components (source) => \n" + CdCoord);

            // convert the 3D Celestiodetic coordinate to 3D Celestiocentric coordinate
            SRM_Coordinate_Valid_Region_Code valRegion =
                CcSrf.changeCoordinateSRF(CdCoord, CcCoord);

            // print out the values of the resulting 3D Celestiocentric coordinate
            System.out.println("CcCoord components (destination) => \n" + CcCoord + " is " + valRegion);
        catch (SrmException ex)
            // catch SrmException and print out the error code and text.
            System.out.println("Exception caught=> " + ex.what() + ", " + ex);

What I would like is use the exposed, public classes from Javascript. I would envision javascript objects (classes) with the same name and methods as in java.

I have a compiled .jar archive and also the source code. It has about 60k lines of code. It only imports java.util.* . There is no UI, just a well defined API.

Would it be feasible to use GWT to transpile to javascript ? If yes, how would I go about it ? I do not want to develop a new web app but use the library in an existing code base. I could not really find a similar example but perhaps there is one ?

I can provide more background if directed to what I should look for. Any tip welcome,


You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment