Whenever we think of java based desktop application what comes to your mind?
Executable JAR or JNLP stuff
Set of libraries
System PATH value/ system variable setup
Registry Entries
Shortcut generation
Branding etc…
To handle this list manually is a time taking and tedious task. What if you get a single setup file that will do this for you? Sounds interesting? After a long-run of net-mining, I found a very use full tool to create windows installer [or setup.exe] that is easy to use and powerful enough to handle all installation parameters.
The most important thing “IT’s FREE…. ”.
The tool is called as “NSIS (Nullsoft Scriptable Install System)”. Even if this tool can be used to create windows installer of any application, as a java junky I will demonstrate it for JAVA.
Following tutorial will brief you about easiest way to get your work done.
.ico file [ to be used as application icon for setup file and application]
[Note: to create .ico file from any image click here]
Step 1
Download NSIS Desktop application installer and install the application
Step 2
Open eclipse IDE and goto:
File Menu -> New -> Other
in next window goto EcplipseNSIS -> NSIS Script and click Next button
[if you don't have EclipseNSIS listed as shown in above figure. Click here to know the process to add the same.]
Step 3
You will get a NSIS welcome screen
Here you can select script templates listed. This templates are having pre-configured option, but we want to set parameters by our self so we will just click on next.
Step 4
On next window you can set:
Application Info
Application Name [Compulsory]
Version : application version
Publisher Name : you may write company or team name here
Publisher URL :
Installer file info:
Installer File [Compulsory]: Name to be given to installer file
Installer Icon : Icon For installer file. here you can use predefined set of icon that is available or custom your own company icon
Uninstaller File info: Same as Installer info
and click next.
Step 5
On next window you can setup the proffered
Installation directory
in drop-down many standard location are referred with $<name>, here we want to install our jar at Program file folder we will use $PROGRAMFILES
Start Menu Group
Here we can control the way in which you application will be listed in the start menu.
There are further configurations for multi-user, multilingual setup but we will not play with them now, as we want to use English language only.
Now click next.
Step 6
Many stylish installer have a welcome animation, this can be introduced in our installer in next interface will help us do it.
License Setting
Here we can add our license file.
Splash Screen
Here you can set welcome animation for our installer.
and click next
Step 7
Now here we will be adding the components the installer will be installing on the client computer.
Default warning
By default, this window will show warning that Main section content are empty as we haven't added anything to it.
Main section Content
Now here select Main section as we want to add content to it.
Add Component
The plus sign button will allow you to add component one by one
Now click green Plus sign
Step 8
As you click on Green Plus sign it will show you the list of component type that can be added:
File
File Set
Folder
Library
Shortcut
Registry Key
Registry Value
As we will want to install our JAR/JNLP we will select file.
Step 10
As you select File following window will open:
where we will be specifying
Source File : i.e. out JAR/Jnlp file
Destination : where we wants to put it after installation
Destination drop-down again contain many standard location specified by $<variable> but as we wants to install it in installation directory only. we will use $INSTDIR and click ok.
[Note : Similarly you can add ICON for application, Desktop shortcut, etc..]
then Click Next.
Step 11
Now this is the final step to generate our install.nsi file
In here we need to select the action that installer should do after completing the installation.
now change installer script save setting to File system and specify the location to save the script and click finish.
Now to start dealing with it we need its integration with
IDE, in order to simplify the work. [NSIS script work can be done with IDE but
it is advised to use them].
The NSIS plugin is not pre-Installed with Eclipse standard setup. So to introduce it in Eclipse we need to do following steps.
As you click Add update selection area will be populated with the list of all possible component provided. You need to select EclipseNSIS from the list.[here i have selected all possible option other than source code but its not a compulsion]. Then click on Next button
Step 3
Next you will see a confirmation page with respective details. Now click Next.
Step 4
Next is Accept the licence and agreement and click Finish button.
As we click on finish the process will start:
As installation processes completes, It will ask you to restart the IDE.
TA...DA...
Our plugin is ready.
You can easily verify the setup. Just goto File Menu --> New --> Other
In this window you will find the EclipseNSIS listed as shown below.
Reason we land-up here is to get answers to the question like:
How to add dynamic image from database in jasper report?
How to get image from database on to jasper report?
How to get image stored in bites to jasper report?
etc ...
Most of the time images are stored in database with predefined
data type [binary, blob, Image]. Retrieving such images to the jasper report is
one of the most common and confusing task encountered in dynamic reporting
implementation process. Following article will provide you a guide to resolve
this need with simple steps.
Note: It is considered that user referring this document
have basic knowledge of creating simple jasper reports with iReport tool.
So here we go:
Prerequisite:
iReport 4.5.1
Sql database with demo table
Exa:
User_Name -> [nvarchar]
USer_Photo -> [Image]
Step 1: [ Create Blank Report ]
Open iReport tool [ i am using iReport version 4.5.1]
Go to File -> New
[ 1. Choose Template ]: In New File window select “Blank
A4”(A) and click on “Lunch report wizard”(B) button
[ 2. Name and Location ]: Specify report name, Location to save on hard disk, Then click next.
[ 3. Query]: At this step you need to provide Connection/data source(you an select from drop down list (A) OR can create new from "New" Button (B)). Then you need to specify the query which will be retrieving data from required table (Query can be written manually (C) OR can be crated with "Design Query" (D) wizard) and click next.
[ 4. Fields ] Select fields to be added in report (click ">>" (A)).Click next
[ 5. Group By...] you can use this section to group clause for your data,(it is optional for this demo) click next and then on new window click Finish.
Step 2: [ Field Configuration ]
After step 1 you will land-up in IDE with your report open in designer view. To the left you can see fields that you fetched from data base (A) and page design components(B).
As you know the User_Photo field is have data type Image in data base, Here while mapping iReport assign java.lang.Object class to it by default. As we want it to show image with image with image element present in iReport we have to change its field class to java.io.InputStream. [Now select User_Photo field go to window menu -> select Properties OR press ctrl+shift+7.]
Go to properties and change Field class to java.io.InputStream
Step 3: [ Design Report ]
Now drag and drop User_Name field from report inspector to Report designer view.
Similarly drag and drop Image and Static Text element from palette.[in case palette window is not there press ctrl+shift+8. While dropping image element it will show new window to select file, just click cancel ]
You can edit content in static text element and format it as per your need
Now select image element (A), go to property window to select Image expression (B).
Once you click button next to Image Expression, it will open new window. In new window bauble-click element which will provide data to display image [ here it will be "User_Photo"]. click OK
Select Image element go to properties and change expression class from java.lang.String to java.io.InputStream
Step 4: [ Test Report ]
Now click on preview tab to get report out-put
And here you have it. Your 1st report with dynamic image data from database.
Enjoy....
Tag : jasper, ireport, jasper report, dynamic image from database, image from database, image from database in jasper report, image in report, .jasper, dynamic jasper report with image