The Artima Developer Community
Sponsored Link

Java Answers Forum
my runtime error :'(

4 replies on 1 page. Most recent reply: Jun 28, 2006 12:40 AM by arnold rock77

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
zeba takmeel

Posts: 10
Nickname: zeba
Registered: Mar, 2006

my runtime error :'( Posted: Mar 19, 2006 7:59 PM
Reply to this message Reply
Advertisement
i need to run this program wich i hav created using jfreechart1.0.1.i hav set the classpath for the jar files n it compiles well.however wenever i try to view it in the appletviewer,it gives me a NoClassDefFoundError-IntervalDataSet.
pls help me solve this..

my code is as follows:-
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.Calendar;
import java.util.Date;
import java.util.StringTokenizer;
//import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.data.gantt.GanttCategoryDataset;
import org.jfree.data.gantt.Task;
import org.jfree.data.gantt.TaskSeries;
import org.jfree.data.gantt.TaskSeriesCollection;
// import org.jfree.data.category.*;
/*
<applet code=Gantt.class width=500 height=500>
<param name="Chart Title" value="Gantt">
<param name="y title" value="abc">
<param name="x title" value="xyz">
<param name="Task Names" value="eating,reading,sleeping">
<param name="StartDate" value="20,10,2006,21,11,2006,30,11,2006">
<param name="EndDate" value="30,12,2006,10,1,2007,11,2,2007">
<param name="PercentComplete" value="0.05,0.15,0.50">
</applet>
*/

public class Gantt extends Applet {
GanttCategoryDataset dataset = ReadParameters();
JFreeChart chart = ChartFactory.createGanttChart(
getParameter("Chart Title"), // chart title
getParameter("y title"), // domain axis label
getParameter("x title"), // range axis label
dataset, // data
false, // include legend
false, // tooltips
false // urls.
);

CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
//renderer.setSeriesPaint(0, Color.blue);



public void init() {
try{
//chart = ChartFactory.createGanttChart(
//getParameter("Chart Title"), // chart title
//getParameter("y title"), // domain axis label
//getParameter("x title"), // range axis label
//dataset, // data
//false, // include legend
//false, // tooltips
//false // urls.

//CategoryPlot plot = (CategoryPlot) chart.getPlot();
//CategoryItemRenderer renderer = plot.getRenderer();


renderer.setSeriesPaint(0, Color.blue);
}
catch(Exception e){System.out.println(e);}


}

/**
*Reads the parameters passed to the applet and builds a GanttCategoryDataset
object
*
* @return The dataset.
*/
Task t;
private GanttCategoryDataset ReadParameters() {
TaskSeriesCollection collection = new TaskSeriesCollection();
try{

TaskSeries s1 = new TaskSeries("Project");//we have just a single series of
//tasks
StringTokenizer taskNames=new StringTokenizer(getParameter("TaskNames"),",");//splits up the task names with
//comma as separator
StringTokenizer startDates=new
StringTokenizer(getParameter("StartDates"),",");//splits up the dates, each date
//is in the format dd,mm,yyyy
StringTokenizer endDates=new StringTokenizer(getParameter("EndDates"),",");
StringTokenizer percentComplete=new
StringTokenizer(getParameter("PercentComplete"),",");

while (taskNames.hasMoreTokens()) {
//create a new task by reading one token from the tasknames parameter, three
//from each date and one from the percentcomplete parameter
t=new Task(taskNames.nextToken(),
date(
Integer.parseInt(startDates.nextToken()),
Int eger.parseInt(startDates.nextToken()),
Integer.parseInt(startDates.nextToken())
),
date(
Integer.parseInt(endDates.nextToken()),
Integer.parseInt(endDates.nextT oken()),
Integer.parseInt(endDates.nextToken())
)
);
t.setPercentComplete(Double .parseDouble(percentComplete.nextToken()));
s1.add(t );//add the new task to the task series

}





collection.add(s1);


}
catch(Exception e){System.out.println(e);}
return collection;
}

/**
* Utility method for creating <code>Date</code> objects.
*
* @param day the date.
* @param month the month.
* @param year the year.
*
* @return a date.
*/
private static Date date(int day, int month, int year) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, --month, day);//month is 0 based 0 is January, 11 is December
Date result = calendar.getTime();
return result;

}

public void paint(Graphics g) {
try{
//this is called automatically when the applet is loaded and resized
if ( chart!=null ) {
chart.draw( (Graphics2D)g,getBounds()); //repaints the whole chart
}

}
catch(Exception e){System.out.println(e);}

}

public String[][] getParameterInfo() {
String[][] info = {
// Parameter Name Kind of Value Description
{ "Chart Title", "string", "The title of the chart" },
{ "X Title", "string", "title for the timeline" },
{ "Y Title", "string", "title for the task lines" },
{ "Task Names", "string", "comma separated list of task names" },
{ "StartDates", "string", "comma separated list of start dates in the format dd,mm,yyyy,dd,mm,yyyy" },
{ "EndDates", "string", "comma separated list of start dates in the format dd,mm,yyyy,dd,mm,yyyy" },
{ "PercentComplete","string", "comma separated list of percentages as decimals" }};
return info;
}
private boolean m_fStandAlone=false;
public static void main(String args[])
{

//frame.resize(frame.insets().left + frame.insets().right + 575,
// frame.insets().top + frame.insets().bottom + 600);

Gantt applet_ganttApplet = new Gantt();

//frame.getContentPane().add(applet_metricsApplet);
applet_ganttApplet.m_fStandAlone = true;
applet_ganttApplet.init();
applet_ganttApplet.start();
//frame.show();
}//check this for package

}


Rob Stone

Posts: 2
Nickname: rstone
Registered: Mar, 2006

Re: my runtime error :'( Posted: Mar 23, 2006 11:52 AM
Reply to this message Reply
You most likely do not have your HTML file containing this code =>

<applet code=Gantt.class width=500 height=500>
<param name="Chart Title" value="Gantt">
<param name="y title" value="abc">
<param name="x title" value="xyz">
<param name="Task Names" value="eating,reading,sleeping">
<param name="StartDate" value="20,10,2006,21,11,2006,30,11,2006">
<param name="EndDate" value="30,12,2006,10,1,2007,11,2,2007">
<param name="PercentComplete" value="0.05,0.15,0.50">
</applet>

in the correct directory. The html file needs to be in the parent directory of the Gantt class's directory.

(i.e. You have a directory called java_applications which contains multiple directories one of which is the Gantt directory containing Gantt.class and Gantt.java. You need to put the HTML file containing this corrected code in the parent directory and replace YourParentDirectory.Gantt.class with the name of your parent directory + .Gantt.class) and that should fix your runtime error.

<applet code=YourParentDirectory.Gantt.class width=500 height=500>
<param name="Chart Title" value="Gantt">
<param name="y title" value="abc">
<param name="x title" value="xyz">
<param name="Task Names" value="eating,reading,sleeping">
<param name="StartDate" value="20,10,2006,21,11,2006,30,11,2006">
<param name="EndDate" value="30,12,2006,10,1,2007,11,2,2007">
<param name="PercentComplete" value="0.05,0.15,0.50">
</applet>

zeba takmeel

Posts: 10
Nickname: zeba
Registered: Mar, 2006

Re: my runtime error :'( Posted: Mar 24, 2006 6:39 AM
Reply to this message Reply
This is what i get each time i run it..please help!!:

java.lang.NoClassDefFoundError: org/jfree/data/category/IntervalCategoryDataset
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-Gantt.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Arul Murugan

Posts: 7
Nickname: appaney
Registered: Mar, 2006

Re: my runtime error :'( Posted: Apr 4, 2006 1:57 PM
Reply to this message Reply
It seems you need to import IntervalCategoryDataset class into your code. And also pls check all the necessary JFree chart jar files are in the class path. I suspect that you missed to specify some jar file in the class path, so double check once again.

import org.jfree.data.category.IntervalCategoryDataset

arnold rock77

Posts: 1
Nickname: arnold77
Registered: Jun, 2006

Re: my runtime error :'( Posted: Jun 28, 2006 12:40 AM
Reply to this message Reply
put your class files and Jfreechart jar files at same folder and try to execute it.
BTW did ur program work?how you solved the problem?bcaz i too have the same problem.I couldn't pass the param to applet.

Flat View: This topic has 4 replies on 1 page
Topic: Servlet to Servlet Communication Previous Topic   Next Topic Topic: Generic Class in Non Generic class

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use