Pages - Menu

Saturday, September 20, 2014

Illegal modifier for parameter ... only final is permitted

A local variable, i.e., method level variable or a parameter cannot be declared as static or public/private/protected.

So local variables must be declared without these modifiers.

For example, the following code is wrong:

    void methodA(static int param) {

        System.out.println(param);
    }

    void methodB(private int param) {

        System.out.println(param);
    }

    void methodC() {

        private static int methodVariable = 10;
        System.out.println(methodVariable);

    }


To resolve the error, remove static and the access modifiers from the local variable declarations. Only the class level variables (declared outside of any method) can be declared with static and access modifiers.

Wednesday, June 11, 2014

This method requires a body instead of a semicolon



The reason for the error "This method requires a body instead of a semicolon" is same as described in the post missing method body, or declare abstract.

Font ' net/sf/jasperreports/fonts/pictonic/pictonic.ttf ...' is not available to the JVM

The full error message is:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
       at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:184)
Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '
                     net/sf/jasperreports/fonts/pictonic/pictonic.ttf
                     net/sf/jasperreports/fonts/pictonic/pictonic.svg
                     net/sf/jasperreports/fonts/pictonic/pictonic.eot
                     net/sf/jasperreports/fonts/pictonic/pictonic.woff
              ' is not available to the JVM. See the Javadoc for more details.


Obviously there might have several reasons for this error. A Google Search or stackoverflow search will bring many results.

For me, in one instance, the problem was with the jasperreports version as I had more that one jasperreports jar in my classpath.

My reports were compiled with jasperreports-5.6.0 and in my classpath jasperreports-4.1.1.jar was also included and accidentally jasperreports-4.1.1.jar was "up" in the Build class path order.

Actually, my eclipse project had jasperreports-5.6.0 as a library jar and this project had another project as "Required projects in the build path" that contained the old version of jasperreports.

I moved the jasperreports-5.6.0 to "Up in the build classpath order" than the old version, and the problem got resolved.

Again, later I removed the project dependency and got the problem resolved as well.

So check, whether you have more than one jasperreports library  anyhow; if so, remove the unnecessary duplicate jar.