Unable to compile the java program which is importing net.sf.jasperreports.engine.jasperCompileManager


I am attaching java program below. Which I am compiling through command line. I am setting the classpath through command line. I have copied jasperReport.5.1.0.jar file in classpath. But stil I am getting

"Package net.sf.jasperReports.engine does not exist" Error. I have used the jar file from jaspersoft community version. I have also copied few other dependent jar files. Nothing is working.

I have jdk1.7 and JRE1.7 and JRE 7.0 in my machine. I do not have JasperReport server in my machine I am having only jaspersoft studio in my machine.

Can somebody help me on this.

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;

import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
//import net.sf.jasperreports.engine.JasperFillManager;
//import net.sf.jasperreports.engine.JasperPrint;

public class AQM_Test {
 public static void main(String[] args) {
  HashMap hm = null;
  System.out.println("Usage: ReportGenerator ....");

  try {
   System.out.println("Start ....");
   // Get jasper report
   String jrxmlFileName = "C:/reports/C1_report.jrxml";
   String jasperFileName = "C:/reports/C1_report.jasper";
   String pdfFileName = "C:/reports/C1_report.pdf";  
  } catch (Exception e) {
   System.out.print("Exceptiion" + e);

visingh's picture
Joined: May 30 2013 - 5:29am
Last seen: 6 years 3 months ago

3 Answers:


it's not clear to me if you tried to create and compile this file from inside Jaspersoft Studio. Moreover which version are you using? Plug-in or stand-alone?
You should be able to see JR packages when creating Java files from inside JSS.

Your project must have the "JasperReports Library" in Build Path. Plus if you are using the standalone version you should be sure to enable "Java Development" capabilities. This can be done via Window > Preferences > General > Capabilities.

Best regards,

mrabbi's picture
Joined: Oct 31 2011 - 9:20am
Last seen: 1 day 12 hours ago

I do have the same issues. I wonder why in 13 years they don't put up a simple sample of how to compile a report from command line / java console app.



d.wendler's picture
Joined: Jun 21 2013 - 7:23am
Last seen: 6 years 1 month ago

I have resolved this problem.

I have added JasperReports-5.1.0.jar file name in classpath by below command

SET CLASSPATH=C:\ABC\JasperReports-5.1.0.jar;C:\ABC\

WHERE C:\ABC\  is the path where my java program file resides. 

Then I compiled the program by below command

javac C:\ABC\JavaProgram.java

Hope it will help you


visingh's picture
Joined: May 30 2013 - 5:29am
Last seen: 6 years 3 months ago