RSS

unsupported major.minor version

Yet another time to look into the resolution of another uncommon type of error encountered in the java world, the ‘unsupported major.minor version’ error. This error majorly occurs during run-time when the java version that was used to compile a java code into a class is different from the java version being used at run-time.

The solution as has been described in this post is to check for the version of the java being used at run-time and make use of the same java version when recompiling your java code (i used the netbeans IDE). Lets take an example of the error message in this way:

unsupported major.minor version 51.0

This message is simply saying the the java version needed is 1.5 and this is contrary to the version found in your application.

How do we resolve the error using the netbeans IDE.

1. Make sure the project is selected in netbeans and then press the ‘F11′ key, it should give you a box as shown below.

netbeans f11

2. Click on Project Properties in the above box, it should give you the box below

netbeans jdk change

3. Change the Source/Binary format (right at the lower part) to the one required and click the ‘ok’ button to save your changes, here I have changed it to version 1.5 as specified in the error. The warning message below should be ignored:

warning: [options] bootstrap class path not set in conjunction with -source 1.6

1 warning

4.You can then recompile and go run your application again.

 
Leave a comment

Posted by on August 18, 2013 in Java

 

Tags: , , , , , , , , , , ,

024 Vintage in Microfinance… How Others Look at It…

024 Vintage in Microfinance… How Others Look at It….

 
Leave a comment

Posted by on July 31, 2013 in Uncategorized

 

Jasper Reports with T24 Jbase

Hello all,

Today we shall be looking at how to generate a simple pdf report from T24 on Jbase with Jasper.  This report retrieves the Mnemonic, Sector and Industry from the Customer table.

Although it is required to have a knowledge of Java to be able to follow this tutorial, contributions and questions would be highly appreciated.

You as a reader might decide to achieve this your own way and this would mean that you do not have to follow this tutorial if you have a better way :)

Lets get started.

Step 1: Create a java class that connects to jbase and performs all the other magic acts

This can be achieved by using any favourite IDE of yours and this tutorial will not be based on any particular IDE. The code snippet of the main class is pasted below.

==============================

package newjsp;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
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 net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;

public class Main {

Connection conn;

public void generateReport() {

try {
Class.forName(“com.jbase.jdbc.driver.JBaseJDBCDriver”);
//This is where you specify the credentials of the database you are connecting to.
conn = DriverManager.getConnection(“jdbc:jbase:thin:@localhost:9494:R09″,”R09″,”123456″);
System.out.println(“Connected…”);
System.out.println(“Loading Report Designs”);
InputStream input = new FileInputStream(new File(“resources/report3.jrxml”));
JasperDesign jasperDesign = JRXmlLoader.load(input);

System.out.println(“Compiling Report Designs”);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

System.out.println(“Creating JasperPrint Object”);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(“ReportTitle”, “PDF JasperReport”);

System.out.println(“Filling Report to File”);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
//System.out.println(“Sector is “+ conn );
//Exporting the report
OutputStream output = new FileOutputStream(new File(“resources/customer.pdf”));
JasperExportManager.exportReportToPdfStream(jasperPrint, output);

System.out.println(“Report Generation Complete”);
conn.close();
} catch (FileNotFoundException e) {
} catch (JRException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
}
}

public static void main(String[] args) {
new Main().generateReport();
}
}
=====================================
Before moving on there are some things that you need to do so as to be able to run the code in step 1 above successfully

1. If you are making use of some extra classes, make sure they have been placed in the right packages in the project and they are error free.
2. You may need to add some jars to your project and one of them is the jdbc jar which should come with your jbase package.

3.Make sure the agent in the database environment specified is running and this can be done using the command “jbase_agent p- <port number> “

4.You can place your questions if you are still having any other problem apart from the ones mentioned above.

Step 2: Create an xml file to be used for the formatting and retrieval of the needed information

This xml file may be created manually or created using tools like Ireport and some others. The fact is just that you should know what you want.

After creating the xml file, save it as a “.jrxml” file and you do not need to compile it to a “.jasper” file

Then specify the link to where you have placed the xml file in your java code. as in step 1.

The xml file used for this tutorial is pasted below.

==================

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE jasperReport PUBLIC “//JasperReports//DTD Report Design//EN”
http://jasperreports.sourceforge.net/dtds/jasperreport.dtd”&gt;
<jasperReport name=”CustomerReport_TeejayT24″>
<queryString>
<![CDATA[SELECT * FROM FBNK.CUSTOMER ]]>
</queryString>
<field name=”MNEMONIC” />
<field name=”SECTOR” />
<field name=”INDUSTRY” />
<title>
<band height=”50″>
<staticText>
<reportElement x=”0″ y=”0″ width=”180″ height=”15″/>
<textElement/>
<text><![CDATA[Jasper Report - Teejay]]></text>
</staticText>
<staticText>
<reportElement x=”0″ y=”30″ width=”180″ height=”15″/>
<textElement/>
<text><![CDATA[Mnemonic]]></text>
</staticText>
<staticText>
<reportElement x=”140″ y=”30″ width=”180″ height=”15″/>
<textElement/>
<text><![CDATA[SECTOR]]></text>
</staticText>
<staticText>
<reportElement x=”200″ y=”30″ width=”180″ height=”15″/>
<textElement/>
<text><![CDATA[INDUSTRY]]></text>
</staticText>
</band>
</title>
<detail>
<band height=”30″>
<textField>
<reportElement x=”0″ y=”0″ width=”69″ height=”24″ />
<textFieldExpression>
<![CDATA[$F{MNEMONIC}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x=”140″ y=”0″ width=”69″ height=”24″ />
<textFieldExpression>
<![CDATA[$F{SECTOR}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x=”200″ y=”0″ width=”69″ height=”24″ />
<textFieldExpression>
<![CDATA[$F{INDUSTRY}]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

================================

Step 3: Make sure all your codes have been compiled and then run it.

A pdf report will be produced in the location you have specified in your program with the retrieved report. A sample of the generated report is as shown below.

Sample pdf report generated

That is all about this tutorial.

Please note that you can also generate any other type of report as supported by JasperReports, this tutorial is based mainly on pdf report generation.

Thanks for following the tutorial and i would also like to acknowledge the works of Suhas on jasper reports

Thanks and Regards.

 
Leave a comment

Posted by on October 20, 2012 in Java

 

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Life Lessons and morals: 5 stories from the Yoruba language and culture

Life Lessons and morals: 5 stories from the Yoruba language and culture.

 
Leave a comment

Posted by on September 21, 2012 in Life Lessons

 

Tags: , , , , , , , , , , , , , , , , ,

Seven Lessons from the Land of Oz

Seven Lessons from the Land of Oz.

 
Leave a comment

Posted by on September 2, 2012 in Office motivation

 

Tags: , , , , , ,

adetunjiadegbite:

All ladies and maybe guys too that will soon clock 18.

Originally posted on adebayoadegbite:

Happy birthday to you (2x)

Happy Birthday to you Deola

HappyBirthday to you

We wish you many happy returns of the day

Long life and Prosperity

HIP! HIP!! HOORAAAY!!!

                 It is appropriate that this piece commemorating your eighteenth birthday starts with the Birthday song popularly known and sung all over the world. Well first of all I have to beg your apologies that I did not write this earlier, well I’m really sorry but then since you are eighteen until next year , I believe I’m still in order. Birthdays as you know, are times to get mushy, and touchy feely, and fall over each other to say how wonderful you have been. But as the wise saying goes “ti omo eni ba daa ka wi, Akuku ni fi se aya” (there is nothing wrong is saying that one’s daughter(or sister in your case) is beautiful,it’s not…

View original 2,193 more words

 
Leave a comment

Posted by on August 1, 2012 in Uncategorized

 
 
Follow

Get every new post delivered to your Inbox.