What is the best approach to use JasperReports? - java

Here we are talking about three main products:
JasperReports: which is just a library to generate reports and fill it
iReport: which is GUI tool to develop templates used by the above library
JasperServer: which is full application with web interface for managing reports with users permissions and other features,
documentation is really not that good, i want to use the best of the above products to integrate JasperReports with my application (Spring/Hibernate), so please advice what is the best approach to do this,
1- design reports using iReport using embedded sql generation, and make it as a separate project from mine, I tried to use Hibernate or Spring within iReport but also I faced a lot of problems and no clear documentation for this part
2- attach it with my project, to use same Hibernate configuration, already created entities
3- try to use JasperServer which seems to be complicated, and then expose reports as webservices
or any other better, guaranteed approach, i know it's dependant on the way my project is dealing, but i've shortage in time, so it depends on the approach having better documentations or tutorials.

You can write your own Jasper framework in a module or subproject. You can maintain report definitions separately from queries and feed them with data produced by your code.
This way all data and handling stays in your project where it's easier to track or edit (e.g. when you only need to change an aspect of the query, add a filter or rewrite it for better performance). Also, this way you can use report data for something else (e.g. add CSV or XML output).

See http://en.wikipedia.org/wiki/JasperReports for the "What is" part of your question.
I faced the same problems when considering to use Jasper-reports in my application, I ended up given it up completely.
Anyway, take a look at this post for more information about different report frameworks for Java. Generating Reports - What works for you?
I wholeheartedly recommend that you take a look at BIRT http://www.eclipse.org/birt/phoenix/
I've used it with both Spring and Hibernate, and have no complain so far.

I can't comment on the other two approaches, but we are using Jasperserver and that seems to be more appropriate if you want to actually use a portal with which people will access their reports.
With this, you create reports in ireport and publish them to the portal. People log in to the portal to access their reports. I don't think you'd use Jasperserver if you were simply embedding it in your application.

I've started using JasperServer-pro recently and tbh I quite like it. As far as I know there seem to be plenty of options in the way of integrating it with existing apps :-
1 -Deploy as standalone server, and
use the WebService API to call into
to generate and return your reports
(these have to be predefined, either
through iReport or JasperServer's
own AdHoc Report Editor.
2- Deploy as standalone server, and do URL
calls through a kicked-off browser
to pull up reports (again
predefined)
3 - (Pro-only) -
Download the WAR BIN installer and
rebrand it.
4 - Download the source
code for JasperServer and build it
from ground up
5 - Download the
source code / JasperReports jars and
borrow the parts you want to use in
your source code.

For JasperReports can you buy documentation. You'll get a book and sample code that can help a lot. I just looked at the website (it's been some time ago I worked with JasperRepors, currently no reporting to do), they have a professional design application as well now: http://www.jaspersoft.com/jasperreports-professional.

Related

Java web application rapid development tool - Driven by meta-data

We are planing to use AngularJS, Bootstrap, jQuery, Javascript, CSS for a web application development.
My boss is suggesting to build a tool that would read the metadata (could be from DB) and build the web application without or less coding. So that in future to add any new pages he would just create/edit the metadata.
To me it seems too complicated and may not be possible as it does not give flexibility. Please suggest.
Upadate:-
Have any one build such tool ? Is it worth the effort ? Or should be a definite no no to such approach ?
I have found one tool called evolutility. http://evoluteur.github.io/evolutility
Have anyone used this ?
Have you looked at WaveMaker? It generates application that matches the stack you mentioned.
Also, your DB seems local, WaveMaker have on premise version which can help.

Packaging up a project for deployment - Java

I have a Java application (a quite large one with many external .jar dependencies as well as dependencies on images) and I need to package it up so that someone can double click to run, for example. Or something easy like that.
It uses Java Persistence, so it requires a sql connection which is specified in the Persistence.xml file in the Java Project.
How can I package this up? I was thinking:
the installation process should validate that the user has MySQL installed and if not, direct them to install it
the installation process could ask the user to enter credentials for any database and then I could update the Persistence.xml at run time
These were two ideas I had...but I wasn't sure if there was a known solution to this problem. Any help would be much appreciated!
I think you should take a look at embedded database solutions, like H2. Also, you can package your application using maven's shadowing or jar plugin, having the jar-with-dependencies profile activated.
This will nicely rid you of checking for database servers running on the client machine, and also will give you the proper means of bundling the application in one nice JAR, albeit a little large.
Maven is a build ecosystem and toolset especially designed for building Java applications and executing the code -- and generally doing whatever else you can imagine that's possible to do with and to your code.
It has a rich API for developing plugins and many developers have exploited this feature. There are numerous plugins for building -- and launching -- and packaging your application as well as helping you manage your applications dependencies.
Maven's shadowing comes in the form of maven-shade-plugin, available here. What it does is that it helps you create a single JAR file from all your dependencies. Also, there is the maven-jar-plugin which offers a profile jar-with-dependencies. It is also accessible from here.
H2, on the other hand is a full-fledged RDBMS. This is the website: http://www.h2database.com/html/main.html, and here is a tutorial.
You can find information on embedding the database here:
How to embed H2 database into jar file delivered to the client?
Embedding the Java h2 database programmatically
h2 (embedded mode ) database files problem
I would also suggest you use a combination of H2/Hibernate/Spring which is a very easy setup and provides you with really rich features and an easy-to-use API.
I hope this helps you :)
Building a sophisticated installer that checks lots of dependencies, and runs on lots of different platforms (which I assume you want) is complicated.
I suggest that you look at an installer generator; see What is the best installation tool for java?
Another alternative that I've seen in a few products is to write a (non-GUI) installer or configurer in a scripting language like Perl.
I wrote an installer using ANT, but has no GUI. Also, I used Iz Pack (good option), so I think that depends on how smart do you want it to be, if you are supposed to use it, or a non-technical person, etc.

What scripting frameworks exist for database-based reporting?

I have to run a lot of relational-database-based reports for my job. In order to make my life easier, I have written a handful of scripts and programs to run a report (simple SQL query, complicated super-specific cross-cutting query, and full JasperReports anything-goes-style reports), compress and/or encrypt it, and deliver it via SMTP to one or more recipients.
Some of this has been written in Java, some in PHP, and some as bash shell scripts. I'd like to unify a lot of this, plus add a single report-description format that can include configuration information like which report (or reports: sometimes I have to run several reports at once and combine them into a single "package" for the client) to run, what any parameters for the report should be set to (customer id, for instance), who should receive the report via email/SFTP/etc.
Note that tools like JasperReports are only part of the solution: the actual report-generation part. I'm more interested in something that can be used to script the whole process and be run from a cron job.
Do any products (OSS would be great) exist to help me with this kind of thing? Or, is this kind of thing so unique to a particular environment as to require the kind of customized tools that I have already built?
Use BIRT that integrates with your Java/J2EE application to produce compelling reports. And the second option is DataVision that is similar to popular Crystal Reports.
It might be a little off what you were thinking about, but have you considered (or heard of) R ? R is an open source statistical programming language that has many features, but specific to your problems is;
Is open source
Has packages that enable interacting with SQL databases (generic ODBC, or specific Oracle, MySQL, Postgres etc)
Can do many kinds of data processing steps with the data
Can produce
tables and graphs
Can produce documents in several ways (LaTex,
Markdown, ODF)
Can be used from the command line, (for instance I
produce documents with make)
Can be integrated into a web server
(RApache)
Can run Java code (RJava)
the only problem is this would be roll your own, there's no specific implementation that offers the features you want.
some frameworks that might help you with configuring report delivery workflow are.
Apache Service Mix http://servicemix.apache.org/ see achitecture diagram froma a previous version http://servicemix.apache.org/home.data/ServiceMix3.png
Spring integration http://static.springsource.org/spring-integration/reference/htmlsingle/
Both should give you a framework for building a decoupled architecture so that the part does report compression and the part that does report encryption and report generation don't know about each other but can be configured via the framework to work in a particular workflow.
Maybe you can check Gradle http://www.gradle.org/. Since it is based on Groovy you can send Mails, package archives and call JasperReports easily.
From Gradle web site:
Gradle is build automation evolved. Gradle can automate the building,
testing, publishing, deployment and more of software packages or other
types of projects such as generated static websites, generated
documentation or indeed anything else.
Gradle combines the power and flexibility of Ant with the dependency
management and conventions of Maven into a more effective way to
build. Powered by a Groovy DSL and packed with innovation, Gradle
provides a declarative way to describe all kinds of builds through
sensible defaults. Gradle is quickly becoming the build system of
choice for many open source projects, leading edge enterprises and
legacy automation challenges.
You might want to take a look at Pentaho: http://www.pentaho.com/explore/pentaho-business-analytics/

Fastest way to code up a quick CRUD app. when I have some reusable java code?

I have to come up with a basic CRUD app. as fast as possible (and by "fast" I mean like 3 days).
I considered going with Django, but I don't have a lot of experience with Python/Django, and also I have a complete set of EntityBeans that I need do CRUD on. So I thought reusing them would be better.
The resulting CRUD app. should be similar to the Django admin page (but the Django admin page per-se won't work though).
Is there some framework with which I can start with EntityBeans and get a quick, Django admin like skeleton?
If you don't want to change a technology stack you're working on and still have an Django-like administration interface, there is a Java alternative - LightAdmin all-in-one library.
After declaring Maven dependency & enabling administration panel in your web.xml, you will have a complete CRUD with some additional features, like filtering, scopes, security, etc.
The only code related to data administration in your codebase would be DSL configurations for UI customization.
The only thing is that LightAdmin could be used only for JPA domain model entities administration for now.
I would recommend the playframework as it is easy to learn and quick to get up and running. They have a CRUD administration module you can use to generate CRUD framework based on your Entity model. Also check out their tutorial page.
You must try AppFuse or Spring Roo.
http://appfuse.org/display/APF/Demos+and+Videos (+online demo)
http://spring.io/
Spring Roo gives you a CRUD application up in 10 minutes. Unlike other frameworks this really is practically usable.
I have downloaded the Roo shell for the first time and without reading any documentation I managed to get an application up and running within minutes.
Naked Objects, if you're look at a prototype. Although it does have a "viewer" for Wicket apart from the HTML viewer, I would recommend using the framework primarily for fleshing out the functionality of your domain.
You might also want to check the Scimpi viewer, although I must admit that I havent worked with it.
A demo application using the HTML viewer is hosted online, and is accessible for having a quick look at the functionality. A tutorial demo is also hosted online.
Give Grails about 2 hours, and if you don't have a CRUD app after that you're doing something wrong.
I've used CodeCharge Studio by Yes Software for several years, and am able to build a CRUD app in less than 10 minutes (assuming database already exists). CodeCharge has a bit of a learning curve if you want to go beyond the interfaces created by the wizards, yet I think my development time has increased by a factor of at least 30 from writing my own code.
I use it at work to create PHP applications that hit MSSQL, and other projects that hit MySQL. Works like a charm for both.
http://www.yessoftware.com/index2.php
I am not a "pythonista" so this may be absolute rubbish but could Django running on Java be the answer for you?
Jython is an implementation of python for the JVM and can run Django.
http://docs.djangoproject.com/en/dev/howto/jython/
Yes Java has many such framework for both web and desktop but .net has very few..
I recently used RocketFramework , which was to my expectation.. So just thought to post it here so that anybody interested have the link :-)
You can create a Quick Crude App in minutes using HTML5, i found www.quickcrud.com that allows you to generate the HTML5 on line and also it's possible to generate Android Apk also in minutes!

Taking the next step with java development?

I want to take the next step in java web development, I am hoping to get insight & feedback on: what my next steps should be and how best to take them.
While learning the basics of java web development, I put together a simple web app that performs simple accounting and financial calculations. The web app is on a single jvm, uses Tomcat, and has standard web functionality - i.e. login/logout, basic security, etc.
How can I make this web app more "enterprise ready" - distribute functionality of tiers over different servers/jvms, HA, balance-able, etc.
What do I need to know/learn? - i.e. EJB3 or Spring Framework (seems spring is better option), REST and/or SOAP, etc.
How would one recommend (books, websites, etc.) I learn the "requirements" (see preceding line)?
Thanks!
In my opinion, you should try different approaches for a same problem, so you could compare the pros and cons of different tools and frameworks.
For instance, try to build an application using EJB, and then the same application using Spring. Take the presentation layer of your code written with JSF and then rewrite it using Tapestry.
I think this will be very helpful to you, as you'll be able to make best decisions when choosing tools for your future developments.
A few things to consider, as food for thought:
How good is the error handling/logging of the application? For example, if the user tries to put in X in for a currency value, what does the application do?
What is configurable within the application from the user and what is in configuration files and what is in a database with regards to configuration? Do you have passwords encrypted within the application?
What patterns would used in building this application? Are there patterns you could see using now that you have a prototype?
Is this application ready to handle different currencies and languages?
What happens if someone leaves the screen for a few hours and tries to use a form?
What administrative functionality does the application have?
Does it handle the case where the user has JavaScript disabled?
What are the limitations of your application, IOW what can't it handle the way it is?
Have you considered trying to write a manual for the application?
EJB or Spring? gets asked quite a lot nowadays, here's a decent related question about them.
Have some real users using your application. You'll be amazed on how many "new" features/improvements can be performed in your app ( and the technologies you'll learn to satisfy those requirements ) by having real users using it.
I would suggest the following books/tutorials are a must for every Java developer:
Manning: Spring in Action - 2nd edition
Manning: Java Persistence with Hibernate
Core JavaServer Faces
Adobe Flex ( Adobe website video tutorials )
Effective Java
Apart from the standard technologies above you must be familiar with
Different testing frameworks , JUnit is a must
Build tools like ANT and Maven
Also you can build small projects by downloading trial versions of MyEclipse or Flex Builder.
I suggest that you create small java experiment projects for each new framework/library that you want to learn.
I've had good success using maven to help me quickly and consistently create java projects that I use to experiment with one technology at a time, such as Spring, Hibernate, etc. I use maven's site life cycle to record notes about what I learned and to document how to build and run each project. So, now I have 20 or so projects that I can use as baseline projects, one for each framework, to build upon.
Also, I prefer buying and reading books rather than relying on google and websites to learn new frameworks. Seems that I'm able to learn a lot faster this way.
I also suggest that you write web apps that you, yourself, would want to use. Or write a web app that solves a problem you've been having. I've found that I learn a lot more this way rather than simply copying and pasting from examples in a text book.
Hope that helps,
- Dave
Spring or Tapestry would be good options for new learnings. Does your app use any web services? If not work those in. Work with other application servers like JBoss and Weblogic and note their nuances with java. I'd also recommend learning Maven and work that into your build/deploy process.
Have fun,
Mike
You could vastly reduce the time taken to build your apps by learning some Test-Driven Development.
Try learning JUnit - it's becoming a core skill now, even in unagile shops.
If you're focussing on the web, try out Selenium - which has a Java controller to drive your tests from Java test cases.
After investing a bit of time in TDD will pay off no matter which frameworks or apps you work on. If you learn to test drive your code, you'll end up with smaller, cleaner code and less debugging.
You might look at AppFuse, which is a bundle of Java things together.
Or, you might take a look at a few more technologies to play with and add in:
Version Control - SVN
Tools - Ant or Maven
Framework - Spring, Seam, Struts
ORM - Hibernate or iBatis
Test Driven Development - JUnit, Emma
Continuous Integration - Hudson
I'd also read the Pragmatic Programmer and/or Code Complete.
Allow me to state that "enterprise"-ready does not necessarily imply scale-out solutions, many, many enterprise Java applications are running on larger systems requiring long-running-systems skill of their own.
I recommend mastering the Java language and runtime, understanding how bytecodes and loading traverse the JVM vs. focus on any given framework.
Speaking of frameworks and if you really have the time, try recreating an application framework yourself. Try and re-invent the wheel. IMO it is an excellent lesson in why frameworks themselves exist and teaches one to employ the features instead of always trying to work around them.
One more thing, never forget the database. I don't care what that looks like Oracle, MySQL or NoSQL, but become also an equal master at the data store.

Categories

Resources