Jump to content
Changes to the Jaspersoft community edition download ×

subtract 2 numbers


Recommended Posts

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:




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

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic



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:






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.


Link to comment
Share on other sites



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.



Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...