I've worked in jGRASP for some time, and just started working with lambda expressions in Java. I can compile programs with lambda expressions, but when I try to run them I always get this error:
No main methods, applets, or MIDlets found in file
Example program:
public class SquareComputer {
interface IntegerMath {
int operation(int a);
}
public int operateUnary(int a, IntegerMath op) {
return op.operation(a);
}
public static void main(String... args) {
SquareComputer myApp = new SquareComputer();
System.out.println(myApp.operateUnary(3, a -> a*a));
}
}
If I comment out the last line, then the program compiles and runs as expected (doing nothing, of course).
Note that this program is a cut-down version of the Calculator example in the Oracle tutorial here. If I use the whole Calculator program, then the same thing happens: compiles but fails to find a main method to run; but comment out the lines using lambda expressions, and it runs fine. Likewise for the other program that I'm really working on; any single line compiled with a lambda expression causes the program to fail to find the main method.
Is this a problem with jGRASP, or my Java installation, or my understanding, or something else? And how can I resolve this?
Edit: A few more data points: If I have jGRASP display a UML diagram, the class with a lambda expression is uniquely marked as "External Class or Interface" (without the lambda expression, it is marked normally as "Project Class").
If I try to make a JAR file via jGRASP, with the regular expression, initially jGRASP cannot find the main-class; but once I specify it, the JAR class is made, and I can run it successfully, with the behavior I wanted, from outside jGRASP.
I was using an out-of-date version of jGRASP (from 2013, before the introduction of lambda expressions to Java in 2014, I believe). Updating my installation of jGRASP to the current version cleared up my problems with finding the main-class when a lambda expression is compiled.
So: Yes, jGRASP does support lambda expressions currently (at least by version 2.0.1_09). But no, it did not prior to the appearance of lambda expressions in Java (sometime after version 2.0.0_03).