Jump to content
We've recently updated our Privacy Statement, available here ×

jeenajeena

Members
  • Posts

    12
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by jeenajeena

  1. Hi. I have a parameter $P{fromDate} of type java.util.Date which I use in a JR reports, on Postgres. I read all this forum's posts but I'm still not able to do a very simple operation: sum a number of days to my parameter and use the resulting date in a subdataset's query. Someone could post a working example, please? Thank you!
  2. jserrachinha wrote: Hi all, >configuration the JasperPrint print = ... is invalid. May be it's a classpath problem. Which classpath are you using?
  3. I'm writing that component. I've got a beta, right now. If you're interested, let me know or stand by, I'll release it as soon as possible (open source, of course).
  4. Of course. I started with this article: http://www.codeproject.com/KB/dotnet/Espresso.aspx which is very very interesting. If you are registered, you can download a full working demo and all the sources. I used the JNI.NET.Bridge.dll and the minijavart.dll from that article. Basically, you need to write a Java class to produce your report. This is the very basic example I used: import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.HashMap; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import java.util.Map; import javax.swing.plaf.synth.Region; public class BeJasper { public BeJasper () { } public static void print(String report, String pdf) { Connection connection; JasperReport jasperReport; JasperPrint jasperPrint; try { Class.forName("org.postgresql.Driver"); System.out.println("loading drivers..."); connection = DriverManager.getConnection("jdbc:postgresql://192.168.100.5:5432/d2000","postgres","mypass"); jasperReport = JasperCompileManager.compileReport(report); // set here your parameters Map parameters = new HashMap(); /* java.util.Date dataDa = new java.util.Date(); java.util.Date dataA = new java.util.Date(); parameters.put("dataDa", dataDa); parameters.put("dataA", dataA); parameters.put("impianto", 8); */ jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, connection); JasperExportManager.exportReportToPdfFile(jasperPrint, pdf); } catch(JRException jrException) { jrException.printStackTrace(); } catch (ClassNotFoundException classNotFoundException) { classNotFoundException.printStackTrace(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } } What we're trying to do, now, is to be able to call BeJasper.print("myReport.jrxml", "result.pdf") from our c# application. Download (and study) the article I suggested you then modify the code to map the Java code listed above. The C# code is quite long, so I'm posting here only the essential public class Prog : JObject { readonly static JMethod _print; static Prog () { clazz = JClass.ForName ("BeJasper"); _ctr = clazz.GetConstructor (); _print = clazz.GetStaticMethod ("print", "(SS)V"); } public virtual void print(string report, string pdf) { _print.CallVoid (report, pdf); } In your app.conf you will also need to specify the right classpath, which in my case is <java.class.path value=".;C:dataprgeclipseBeJasperbin;C:ProgrammiJavajre1.5.0_15librt.jar;C:ProgrammiJavajre1.5.0_15libjsse.jar;C:ProgrammiJavajre1.5.0_15libjce.jar;C:ProgrammiJavajre1.5.0_15libcharsets.jar;C:ProgrammiJavajre1.5.0_15libextdnsns.jar;C:ProgrammiJavajre1.5.0_15libextlocaledata.jar;C:ProgrammiJavajre1.5.0_15libextsunjce_provider.jar;C:ProgrammiJavajre1.5.0_15libextsunpkcs11.jar;C:ProgrammiiReportlibmysql-connector-java-3.1.11-bin.jar;C:Programmijasperreportsdistjasperreports-2.0.5.jar;C:Programmijasperreportslibitext-1.3.1.jar;C:Programmijasperreportslibjdt-compiler-3.1.1.jar;C:Programmijasperreportslibcommons-beanutils-1.7.jar;C:Programmijasperreportslibcommons-collections-2.1.jar;C:Programmijasperreportslibcommons-digester-1.7.jar;C:Programmijasperreportslibcommons-javaflow-20060411.jar;C:Programmijasperreportslibcommons-logging-1.0.2.jar;C:Programmijasperreportslibcommons-logging-api-1.0.2.jar;C:ProgrammiEclipsepluginsorg.eclipse.core.commands_3.3.0.I20070605-0010.jar;C:ProgrammiEclipsepluginsorg.eclipse.equinox.common_3.3.0.v20070426.jar;C:ProgrammiPostgreSQLjdbcpostgresql-8.2-506.jdbc3.jar;C:dataprgjasperd2000extensionsMyUtil.jar"/> (MyUtil.jar is a helper class I wrote which is included in my reports) I got crazy with classpath, so I adopted this solution: I created a libraries.jar containing all the jars needed for JR (find here a list http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/jasperreports/requirements.html or use the classpath I wrote above); doing that, deployment of your application is much easier and you'd need just to write <java.class.path value=".;./libraries.jar"/> After all that, all you need to generate a report is something like Prog jasperBride = new Prog(); jasperBride.print("sold.jrxml", "result.pdf"); // You can also use parameters, if you write a suitable method jasperBride.print("sold2.jrxml", "result.pdf", parameters); I'm very sorry this is still very confusing: actually, I got this result yesterday night and I'm still working on a cleanup. I'm going to publish a dll with all that's needed (and may be clear and detailed article too) so if your interested, please keep in touch (my email is jeenajeena (at) hotmail.com) Post edited by: jeenajeena, at: 2008/03/28 11:06 Post edited by: jeenajeena, at: 2008/03/28 11:13
  5. I was able to launch JasperReports reports from a .Net application, using JNI.NET Anyone interested?
  6. Thanks for the help ;) Fortunately, I was able to solve it. The solution is: - always include the directory containing your main class file in CLASSPATH - you have to specify JARs' full path (including filenames) in CLASSPATH: directory name is not enough I guess this was obvious for any Java programmers. Unluckly I come from C#, so everything was new. If you're a C# developer approaching to JR, please, keep in touch, we could share informations Post edited by: jeenajeena, at: 2008/03/28 11:44
  7. Hi, I'm having a problem (probably with CLASSPATH). I was able to compile and run a Java program to launch my JR reports, using Eclipse. The problem is: as long as I run the program with Eclipse, everything is ok. When I try with java Prog I obtain Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) I think included in CLASSPATH everything listed in Eclipse (and I already googled like a crazy, trying all the proposed solutions). Do you have any suggestions?
  8. I'm working to solve the same issue. The solution I found is using a bridge between Java and .NET able to allow me to call directly Java class methods from my C# code. I'm having problems with classpath, at the moment, but I'm going to make it work. Wanna collaborate?
  9. You were right: everytime I change my Java code I have to restart iReport. It's a bit annoying but it works. Thank you!
  10. While iReport remembers Query window's size, the same doesn't happen with subdataset's query window. It's a bit annoying. I also noticed some minor bugs. 1. Subdataset's query window has a the wrong title "Report query". 2. "Ok" button has a wrong size 3. Almost every window forgets it's size (see for example Parameters in Subdataset): usually, default sizes are very small and you always need to enlarge it. Why? Let each window remember it's size or, plese, set the default window and column's size to a more confortable value... Thank you!
  11. I wrote this class public class MyUtil { public static int getLastDayOfMonthXXX() { return 10; } public static int getLastDayOfMonth() { return 10; } } I compiled it and added it's directory to classpath, throu iReport. If I use this expression in a field new Integer(MyUtil.getLastDayOfMonth()) everything is OK. But if I use new Integer(MyUtil.getLastDayOfMonthXXX()) I obtain the error: Error filling print...Error evaluating expression : source text : new Integer(MyUtil.getLastDayOfMonthXXX()) java.lang.NoSuchMethodError : MyUtil.getLastDayOfMonthXXX()I Why? What I'm trying to do is define a bunch of static methods to be used in fields' expressions. May be I'm using the wrong approach.. Any help will be very appreciated
  12. JasperReports is a wonderful piece of code. Unfortunately the company where I'm working is developing a WinForms app in C#. Nevertheless we'd like to use JasperReports. As far as we know, there are 4 few methods to take advantage of JasperReports with C#. We could use IKVM or just call Jasper as an external application with system(), or use the C# client for JasperServer. Unfortunately, there aren't so many infos about JasperReports & C#. Could you suggest us some links or some informations? Thank you! Jeena
×
×
  • Create New...