jbegleyc Posted August 5, 2006 Share Posted August 5, 2006 I am new to Jasper Reports and I am trying to put togather my first report. All I want to do is create a variable that subtracts 2 numbers: $F{actual}-$F{forcast} I can not seem to get this to work and can not find any examples. I keep getting a compile error: '- operator invalid for java.lang.Double' what could I be doing wrong here? Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 7, 2006 Share Posted August 7, 2006 Hi, Note that those should be valid Java expressions.And in Java you cannot subtract Double ojects just like that (unless you are using JDK 1.5 syntax). So, you either try: new Double($F1{actual}.doubleValue() - $F2{}.doubleValue(forcast)) Or, you could learn how to config the JDT compiler for 1.5 compatibility here: http://sourceforge.net/mailarchive/forum.php?thread_id=8390023&forum_id=7912http://sourceforge.net/mailarchive/forum.php?thread_id=8391557&forum_id=7912http://sourceforge.net/mailarchive/forum.php?thread_id=8401091&forum_id=7912 Another approach would be to use the Groovy compiler.Check the supplied /demo/samples/groovy sample in our project distribution to see how simplified expression syntax could be used thanks to the Groovy language. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
jbegleyc Posted August 7, 2006 Author Share Posted August 7, 2006 Teodor, Funny thing is I thought I had tried that before but it didn't work. It worked when I did it this time though so I must have typed something wrong. Thank you for your help and I will check out the Groovy compiler when I get a chance. Jeff Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now