Jump to content
Changes to the Jaspersoft community edition download ×

How to run JasperReports with Java 8?


effingen
Go to solution Solved by effingen,

Recommended Posts

I can't compile tempaltes with JRJdtCompiler because jdtcore:3.1.0 does not support java 8.

Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files[/code]

I can't use JRJdk13Compiler, cause it can't compile templates which use functions.

  symbol:   method DATEFORMAT(Date,String)  location: class report_1414506137290_237400/Users/Mariusz/Work/coresuite-cloud/dataCloud/report_1414506137290_237400.java:255: error: cannot find symbol                value = DATEFORMAT(((...[/code]

I know Java 8 is not yet supported, but is there some workaround? If not, is there some ETA? I wouldn't like to implement my own JRCompiler.

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

I tried simple update of eclipse jdt lirbary and it seems to be working.

            <dependency>                <groupId>net.sf.jasperreports</groupId>                <artifactId>jasperreports</artifactId>                <version>5.6.1</version>                <exclusions>                    <exclusion>                        <groupId>eclipse</groupId>                        <artifactId>jdtcore</artifactId>                    </exclusion>                </exclusions>            </dependency>            <dependency>                <groupId>org.eclipse.jdt.core.compiler</groupId>                <artifactId>ecj</artifactId>                <version>4.4</version>            </dependency>[/code]
Link to comment
Share on other sites

  • 3 weeks later...

Here's what I did:

- I downloaded ecj-4.4.1.jar for the JDT core compiler

- I pointed my project's class path to include that jar and removed any reference to any other JDT core jar

- (I looked into jasper 5.6.1 but the jar file didn't have any pom.xml file so it must configure things differently, so I stayed with jasper 3.7.1.1)

- I got into jasperreports-3.7.1.1.jar then META-INFmavenjasperreportsjasperreports and edited the pom.xml within that folder with the following changes:

net.sf.jasperreports

jasperreports

3.7.1.1

eclipse

jdtcore

eclipse

ecj

4.4.1

compile

- even after I rebuild and restart my project, I keep getting the following When my Java code calls: JasperCompileManager.compileReportToFile(JasperDesign p1, String p2);

 

org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.(ClassFileReader.java:329)

 

Link to comment
Share on other sites

It seems that you include Jasper library differently than I do. In my case Maven is doing all dependency resolving, and that is why I need to have pom.xml in the root directory of my project.

 

Are you using Maven? Or did you just downloaded Jasper and included it in your lib directly?

Link to comment
Share on other sites

The latter. Until now we have simply been using 2 jar files among all of our other jars in a lib folder. One is the Jasper Reports JAR and the other is a jar with the JDT core code. Prior to JDK8, everything worked by itself when loading/compiling Jasper jrxml files on the fly from Java code.
Link to comment
Share on other sites

  • 1 year later...

Thanks to effingen and having made changes to plugin as advised I was able to compile reports with Java 8.

Sorry, can not figure out how to format it nicely, anyway here it is

 

org.codehaus.mojo

jasperreports-maven-plugin

1.0-beta-2

${project.basedir}/src/main/webapp/templates/

${project.basedir}/src/main/webapp/templates/

compile

compile-reports

net.sf.jasperreports

jasperreports

4.7.0

eclipse

jdtcore

org.eclipse.jdt.core.compiler

ecj

4.4.2

org.codehaus.groovy

groovy-all

1.7.5

 

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...