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..
/** *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
/** * 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[]) {
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.
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)
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.
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.