aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Error while running in ecllipse. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Error while running in ecllipse." Watch "Error while running in ecllipse." New topic
Author

Error while running in ecllipse.

Potter James
Greenhorn

Joined: Aug 18, 2008
Posts: 9
Iam getting this type of error when i run the froll code in ecllipse.But this is not happening in case netbeans.Also i included the jar files.

import java.io.*;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperRunManager;
import java.sql.*;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperReport;
import java.util.HashMap;

public class as
{
public static void main(String[] args)
{

try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c= DriverManager.getConnection("jdbc dbc:access1","","");
System.out.println("starting");
JasperCompileManager.compileReportToFile("D:\\ALL IBM PROJECTS\\projects\\test\\WebContent\\WEB-INF\\test.jrxml");
//JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null,c);

JasperFillManager.fillReportToFile("D:\\ALL IBM PROJECTS\\projects\\test\\WebContent\\WEB-INF\\test.jasper",new HashMap(),c);
JasperViewer.viewReport(jasperPrint);
System.out.print("starting and now ending");
}
catch (Exception e)
{
String connectMsg = "Could not create the report "+ e.getMessage() + " " + e.getLocalizedMessage();
System.out.println(connectMsg);
}

}
}
And the error

Exception in thread "main" java.lang.NoClassDefFoundError: org/jfree/util/PublicCloneable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitChart(JRFillObjectFactory.java:719)
at net.sf.jasperreports.engine.base.JRBaseChart.visit(JRBaseChart.java:610)
at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:91)
at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(JRFillElementGroup.java:86)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(JRFillElementContainer.java:91)
at net.sf.jasperreports.engine.fill.JRFillBand.<init>(JRFillBand.java:87)
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:522)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:528)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:59)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:188)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:94)
at a.as.main(as.java:47)

Can anyone help me out..I am in great need of it.
Potter James
Greenhorn

Joined: Aug 18, 2008
Posts: 9
sorry change the code to the foll one

import java.io.*;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperRunManager;
import java.sql.*;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperReport;
import java.util.HashMap;

public class as
{
public static void main(String[] args)
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c= DriverManager.getConnection("jdbc dbc:access1","","");
System.out.println("starting");
JasperDesign jasperDesign = JRXmlLoader.load(new File("D:\\ALL IBM PROJECTS\\projects\\test\\WebContent\\WEB-INF\\test.jrxml"));
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null,c);
JasperViewer.viewReport(jasperPrint);
System.out.print("starting and now ending");
}
catch (Exception e)
{
String connectMsg = "Could not create the report "+ e.getMessage() + " " + e.getLocalizedMessage();
System.out.println(connectMsg);
}
}
}
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi James,

The clue here is that it can't find the org/jfree/util/PublicCloneable on your CLASSPATH in eclipse.

Now I think you stated that this is occurring at runtime so you'll need to edit the run configuration in eclipse (under the run menu)


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Potter James
Greenhorn

Joined: Aug 18, 2008
Posts: 9
Can you tell what the changes must i do.Also say me where it must be done in run...
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

OK, I'll try to be a little more specific .

1.) You are missing the JAR file from your CLASSPATH which holds the org.jfree.util.PublicCloneable class, you'll need to find out what that jar file is.

2.) If you click on the "Run" menu in Eclipse you'll see a menu option there called "Run Configurations". In there you'll be able to add the location of the JAR file to your CLASSPATH for the code you are trying to run.
Potter James
Greenhorn

Joined: Aug 18, 2008
Posts: 9
Thanks Martijn ,I finally came out of that error.I added a jar file called JCommon.jar to solve it .But now i landed in an another error

Exception in thread "main" java.lang.NoSuchMethodError: org.jfree.ui.RectangleInsets.<init>(DDDD)V
at org.jfree.chart.plot.Plot.<clinit>(Plot.java:192)
at org.jfree.chart.ChartFactory.createPieChart3D(ChartFactory.java:690)
at net.sf.jasperreports.engine.fill.JRFillChart.evaluatePie3DChart(JRFillChart.java:2097)
at net.sf.jasperreports.engine.fill.JRFillChart.evaluateChart(JRFillChart.java:1316)
at net.sf.jasperreports.engine.fill.JRFillChart.evaluateRenderer(JRFillChart.java:1237)
at net.sf.jasperreports.engine.fill.JRFillChart.resolveElement(JRFillChart.java:2998)
at net.sf.jasperreports.engine.fill.JRFillElement.resolveElement(JRFillElement.java:895)
at net.sf.jasperreports.engine.fill.JRBaseFiller.resolveBoundElements(JRBaseFiller.java:1396)
at net.sf.jasperreports.engine.fill.JRBaseFiller.resolveBoundElements(JRBaseFiller.java:1421)
at net.sf.jasperreports.engine.fill.JRBaseFiller.resolveReportBoundElements(JRBaseFiller.java:1431)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummary(JRVerticalFiller.java:907)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:286)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:120)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:889)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:792)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at a.as.main(as.java:28)
When i searched in I came to know that this can be solved by adding jcommon.jar..But also this error is not going..
Is anyone having experience in solving this kind of situation.

[ September 15, 2008: Message edited by: Potter James ]
[ September 15, 2008: Message edited by: Potter James ]
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi James,

Good to see progress! If you look at the error it's telling you that it cannot find that method. That means you are using a version of the class/jar that is not compatible with what you are trying to do. You'll need to use the Jar that contains the 'correct' version.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Congratulations on the "Rancher" handle, Martijn.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Originally posted by Campbell Ritchie:
Congratulations on the "Rancher" handle, Martijn.


Thanks Campbell, I've found this place to be a great community for guiding me to answers (and not to mention proving me wrong on more than one occasion!), glad I can help out in return
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Originally posted by Martijn Verburg:
Thanks Campbell, I've found this place to be a great community for guiding me to answers (and not to mention proving me wrong on more than one occasion!), glad I can help out in return


Me too
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error while running in ecllipse.