Hi,
I am trying to run a script from a java class. When I run the script I get the following error:
        Typed variable declaration : Class: SimpleDateFormat not found in namespace

My questions is, how do I get the class loader into the interpreter so I can create any of the base java objects?
If I comment out where it is using the SimpleDateFormat, I get an error trying to create one of my classes that is in the same package as the class I am calling the script from. So how do I get the class loader information into the script?

My Java code looks like this:

private List doCalculation(Hashtable allData, Date startDate, Date endDate) {          
        List returnData = new ArrayList();
        Interpreter interpreter = new Interpreter();

// I have tried messing with class loaders but still not working
//      interpreter.setClassLoader(ClassLoader.getSystemClassLoader());
// Or I tried this?
//      BshClassManager bshCM = new BshClassManager();
//      bshCM.setClassLoader(ClassLoader.getSystemClassLoader());
//      NameSpace ns = new NameSpace(bshCM, "com.test.this");
//      interpreter.setNameSpace(ns);
       
       
        try {
                interpreter.set("startDate", startDate);
                interpreter.set("endDate", endDate);
                interpreter.set("allData", allData);
               
                interpreter.source("LocationOfMyScript.bsh");
                       
                returnData = (List) interpreter.get("calculatedData");

                } catch (EvalError e) {
                        e.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                }
       
        return returnData;
}      



My Script looks like this:
String getValueForDate(List fromThisCollection, Date thisDate){
                SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
               
                for (Iterator iter = fromThisCollection.iterator(); iter.hasNext();) {
                        GenericDataInterface data = (GenericDataInterface) iter.next();
                        if (sdf.format(data.getStartDate()).equals(sdf.format(thisDate)) ){
                                // we found the matching data
                                return data.getValue();
                        }
                }
                // if we get here then we didn't find a matching date
                return "0";
}// end function


// I need to loop the dates so I can perform the calculation

//              I also tried messing with the namespace here but it then gives me
//                      an error about my passed in "startDate" value is not reconginized
//              setNameSpace( this.caller.namespace );
               
                Calendar calStart = Calendar.getInstance();
                calStart.setTime(startDate);

                List grossData = (List) allData.get("Gross");
                List auxData = (List) allData.get("Aux");

                Date tempDate = startDate;
                SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
                List calculatedData = new ArrayList();
               
                while (tempDate.before(endDate) || tempDate.equals(endDate)) {
                        System.out.println("TempDate=" + sdf.format(tempDate));
                        String grossStringValue = getValueForDate(grossData,tempDate);
                        String auxStringValue = getValueForDate(auxData,tempDate);
                        try {
                               
                                long grossValue = Math.round(Double.parseDouble(grossStringValue));
                                long auxValue = Math.round(Double.parseDouble(auxStringValue));
                                long netValue = grossValue - auxValue;
                               
                                GenericDataInterface genericData = new GenericData();
                                genericData.setDataName(this.name);
                                genericData.setStartDate(tempDate);
                                genericData.setValue(String.valueOf(netValue));
                                calculatedData.add(genericData);
                               
                        } catch (Exception e) {
                                System.out.println(e);
                        }
                       
                        calStart.add(Calendar.MONTH, 1);
                        tempDate = calStart.getTime();
                }

Any clue as to what I am doing wrong?

Thanks for taking the time to look at this,
Dennis