3

I have an application developed in NetBeans 8.1 with iReport and JasperReport version 5.5.0 plugin. In my application, I have a jasper report with a JRBeanCollectionDataSource.

LocalDate dateFrom = jDateChooser1.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate dateUntil = jDateChooser2.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
List<Registru> regs = db.getRegistreFrom(dateFrom, dateUntil);

Map<String, Object> params = new HashMap<>();
String absolutePath = "....\\rapoarte\\";
params.put("SUBREPORT_DIR", absolutePath);
InputStream in = getClass().getResourceAsStream("/rapoarte/registreListare.jasper");
JasperPrint jp = JasperFillManager.fillReport(in, params, new JRBeanCollectionDataSource(regs,false));

// ... code here

JRBeanCollectionDataSource takes a parameter of List of Report class returned from the database

public class Registru {
   private int id;
   private int nrReg;
   private LocalDate date;
   // ... getters and setters
}

The problem is that in the report the fields are :

<field name="id" class="java.lang.Integer"/>
<field name="nrReg" class="java.lang.Integer"/>
<field name="date" class="java.time.LocalDate"/>

but when I compile it, it gives me an error

java.time.LocalDate cannot be resolved to a type

It works only if I put <field name="date class="java.lang.Object"/> but I cannot format the date.

I want to format the date of pattern "dd-MM-yyyy". Do I have to add something to the jasper's classpath?

Burnaki
  • 29
  • 4
  • I gave up to use jasper reports plugin in netbeans and I started to use JasperStudio to create and compile jrxml files . But It was easyear to work with all files under NetBeans. – Claudiu-Florin Stroe Aug 22 '16 at 08:28

1 Answers1

1

This problem is related to the JTD compiler (compiler for the jrxml) that you are using.

You will need a recent version of Eclipse Java Compilers (ecj) to use java-8, check the jasper-distribution.

To use pattern on the java.time.LocalDate or java.time.LocalDateTime see this question for more information

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • I'm using Netbeans 8.1 with following plugins : iReport-5.5.0.nbm, jasperserver-plugin-5.5.0.nbm , jasperreports-components-plugin-5.5.0.nbm. How can I change the Java Compiler? Thanks – Claudiu-Florin Stroe Aug 22 '16 at 07:39
  • Check what JDT compiler you are using currently search for ecj or Jdt-compiler, basically remove old one from class path and set new one ejc to classpath. However my advice is to not use plugins (I use iReport installed or JasperSoft Studio) to avoid plugin problems. – Petter Friberg Aug 22 '16 at 19:54
  • Just to complement http://community.jaspersoft.com/questions/844403/how-run-jasperreports-java-8 – Gilberto Oct 18 '17 at 19:12