jfree does not run under linux :-(

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Fry
Posts: 14
Joined: Mon Aug 08, 2005 9:56 pm
Location: Karlsruhe (Germany)

jfree does not run under linux :-(

Post by Fry » Mon Aug 08, 2005 10:05 pm

Hello :D

i just saw jfree and the chart and was happy to find such great classes for drawing diagramms. But i was wondering, because i use linux and this does not work.

first of all:
- i use suse 9.2
- jdk1.5.0_04 (in /usr/java/jdk1.5.0_04/)
- i installed jfree in the directory /usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/
- i add the two files in the PATH Variable ( echo $PATH: .... /usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/lib/jcommon-1.0.0-rc1.jar:/usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/lib/jfreechart-1.0.0-rc1.jar ... )

so, when i run a example from web, that doesnt work. :( Why? If i try the demo whats inside the directory ( java -jar jfreechart-1.0.0-rc1-demo.jar
) its works :D
When i use Eclipse all the packages and import statements are red, because it does not find it.

What wrong here? Can you help me please?
Thx
Fry :D

dhchou
Posts: 138
Joined: Tue Jul 05, 2005 11:01 pm

Post by dhchou » Mon Aug 08, 2005 10:43 pm

Did you install WebStart on your Linux box?

Daniel

Fry
Posts: 14
Joined: Mon Aug 08, 2005 9:56 pm
Location: Karlsruhe (Germany)

Post by Fry » Tue Aug 09, 2005 2:00 pm

Hi Daniel,

no, i just installed it now. I checked the functionallity at the domos from sun. This works now.
But how can i get my Example running? I tried to complie again, but it does not work. Perhaps do you now a little example which work, so that i can be sure thats not a problem in the example?

Fry

dhchou
Posts: 138
Joined: Tue Jul 05, 2005 11:01 pm

Post by dhchou » Tue Aug 09, 2005 2:27 pm

I assume you installed WebStart using sudo or an Administrator account.

When WebStart is installed properly, the demo should launch with a Java WebStart dialog asking you for permission to run the demo. You do not need to compile the WebStart version of the demo.

Daniel

P.S. You would not get the source code of the demo programs unless you purchase the JFreeChart Developer Guide.

Fry
Posts: 14
Joined: Mon Aug 08, 2005 9:56 pm
Location: Karlsruhe (Germany)

Post by Fry » Tue Aug 09, 2005 6:30 pm

Hey,

first, i mean not the complete source code. I picked up an example from informit
well, ok i dont look over the example but here it is:

Code: Select all

package com.javasrc.charts;

// Import the Swing classes
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

// Import the JFreeChart classes
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.*;
import org.jfree.data.general.*;

public class PieChartExample extends JPanel
{
  // Holds the data
  private DefaultPieDataset dataset = new DefaultPieDataset();

  // Create a set of charts
  private JFreeChart chart1;
  private JFreeChart chart2;
  private JFreeChart chart3;
  private JFreeChart chart4;

  // Create a set of panels that can show charts
  private ChartPanel panel1;
  private ChartPanel panel2;
  private ChartPanel panel3;
  private ChartPanel panel4;

  public PieChartExample()
  {
    // Initialize the dataset
    dataset.setValue( "California", new Double( 10.0 ) );
    dataset.setValue( "Arizona", new Double( 8.0 ) );
    dataset.setValue( "New Mexico", new Double( 8.0 ) );
    dataset.setValue( "Texas", new Double( 40.0 ) );
    dataset.setValue( "Louisiana", new Double( 8.0 ) );
    dataset.setValue( "Mississippi", new Double( 4.0 ) );
    dataset.setValue( "Alabama", new Double( 2.0 ) );
    dataset.setValue( "Florida", new Double( 20.0 ) );

    // Create the charts
    chart1 = ChartFactory.createPieChart(
      "Driving Time Spent Per State (Flat Pie Chart)", // The chart title
      dataset,         // The dataset for the chart
      true,          // Is a legend required?
      true,          // Use tooltips
      false          // Configure chart to generate URLs?
    );
    chart2 = ChartFactory.createPieChart(
      "Driving Time Spent Per State (Exploded Pie Chart)", // The chart title
      dataset,         // The dataset for the chart
      true,          // Is a legend required?
      true,          // Use tooltips
      false          // Configure chart to generate URLs?
    );
    PiePlot plot = ( PiePlot )chart2.getPlot();
    plot.setExplodePercent( 3, 0.25 );

    chart3 = ChartFactory.createPieChart3D(
      "Driving Time Spent Per State (3D Pie Chart)", // The chart title
      dataset,         // The dataset for the chart
      true,          // Is a legend required?
      true,          // Use tooltips
      false          // Configure chart to generate URLs?
    );
    chart4 = ChartFactory.createPieChart3D(
      "Driving Time Spent Per State (3D with Transparency)", // The chart title
      dataset,         // The dataset for the chart
      true,          // Is a legend required?
      true,          // Use tooltips
      false          // Configure chart to generate URLs?
    );
    PiePlot3D plot4 = ( PiePlot3D )chart4.getPlot();
    plot4.setForegroundAlpha( 0.6f );

    // Create this panel
    this.setLayout( new GridLayout( 2, 2 ) );
    this.panel1 = new ChartPanel( chart1 );
    this.panel2 = new ChartPanel( chart2 );
    this.panel3 = new ChartPanel( chart3 );
    this.panel4 = new ChartPanel( chart4 );
    this.add( panel1 );
    this.add( panel2 );
    this.add( panel3 );
    this.add( panel4 );
  }

  public static void main( String[] args )
  {
    JFrame frame = new JFrame( "My Trip Driving From CA to FL..." );
    PieChartExample chart = new PieChartExample();
    frame.getContentPane().add( chart, BorderLayout.CENTER );
    frame.setSize( 640, 480 );
    frame.setVisible( true );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
  }
} 
i mentioned such an example. when i try to compile it with

Code: Select all

javac <name>.java
it return this errors

Code: Select all

PieChart.java:14: class PieChartExample is public, should be declared in a filenamed PieChartExample.java
public class PieChartExample extends JPanel
       ^
PieChart.java:9: package org.jfree.chart does not exist
import org.jfree.chart.*;
^
PieChart.java:10: package org.jfree.chart.plot does not exist
import org.jfree.chart.plot.*;
^
PieChart.java:11: package org.jfree.data does not exist
import org.jfree.data.*;
^
PieChart.java:12: package org.jfree.data.general does not exist
import org.jfree.data.general.*;
^
PieChart.java:17: cannot find symbol
symbol  : class DefaultPieDataset
location: class com.javasrc.charts.PieChartExample
  private DefaultPieDataset dataset = new DefaultPieDataset();
          ^
PieChart.java:20: cannot find symbol
symbol  : class JFreeChart
location: class com.javasrc.charts.PieChartExample
  private JFreeChart chart1;
          ^
PieChart.java:21: cannot find symbol
symbol  : class JFreeChart
location: class com.javasrc.charts.PieChartExample
  private JFreeChart chart2;
          ^
PieChart.java:22: cannot find symbol
symbol  : class JFreeChart
location: class com.javasrc.charts.PieChartExample
  private JFreeChart chart3;
          ^
PieChart.java:23: cannot find symbol
symbol  : class JFreeChart
location: class com.javasrc.charts.PieChartExample
[...and so on]
so i thought that has something to do with the classes, because the compiler dont find them. Am i right?

Now to your questions:
When i launch such a webstartapplication, my firefox ask me what do do with <name>.jnlp
Here is already the right path to webstart shown, so i just click "open with" and it starts. then the webstartlogo appears, and after this the application is on.

but what about the charts now? :roll:

Thx for your help :)
Fry

dhchou
Posts: 138
Joined: Tue Jul 05, 2005 11:01 pm

Post by dhchou » Tue Aug 09, 2005 6:43 pm

I'm glad that you got the demo working under WebStart. You can get an idea of what's possible with JFreeChart by selecting the various charts included in the demo.

As for you example, it looks like you are not setting classpath correctly. The Java compiler cannot find the JFreeChart JAR file. Also make sure you import the class you want to use.

Daniel

Fry
Posts: 14
Joined: Mon Aug 08, 2005 9:56 pm
Location: Karlsruhe (Germany)

Post by Fry » Tue Aug 09, 2005 6:59 pm

Hoi,

ok i set explicit the PATH.

echo $PATH show me now the following:

Code: Select all

echo $PATH
:/usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/lib/jfreechart-1.0.0-rc1.jar:/usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/lib/jcommon-1.0.0-rc1.jar:/usr/java/jdk1.5.0_04/bin/
Whats wrong with it?

Fry

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Tue Aug 09, 2005 7:21 pm

Hi,

$PATH is used to look for executables (the same way it is done in DOS/Windows), it has nothing to do with Java's $CLASSPATH variable.

Following the Java-Beginners tutorial from Sun might be a good idea: http://java.sun.com/developer/onlineTra ... djava.html

Btw.: Using an IDE instead of using the command line tools will save you a lot of trouble and frustration later. Hey, even C-Programmers do not use the pure command line anymore ;)

Have mo' fun,
said Thomas

Fry
Posts: 14
Joined: Mon Aug 08, 2005 9:56 pm
Location: Karlsruhe (Germany)

Post by Fry » Tue Aug 09, 2005 9:44 pm

Hello :D

Thomas you was right, it was my misstake of understanding PATH and CLASSPATH. Now it works,...i think so ;-)

solution:

So when i change it with:

Code: Select all

export CLASSPATH=$CLASSPATH:/usr/java/jdk1.5.0_04/jfreechart-1.0.0-rc1/lib/jfreechart-1.0.0-rc1.jar:/usr/java/jdk1.5.0_04/lib/jconsole.jar
there are much less errors :D
In Eclipse i always found it:
Rightclick on your package and then add the path Java Build Path --> Libaries

Thx all :D
Fry

note: it really works ;-) ;-) ;-)

folklayer
Posts: 3
Joined: Tue Aug 02, 2005 10:58 pm

Post by folklayer » Wed Aug 10, 2005 1:49 am

you should not expect user have jfree installed in his classpath; you might package the jfree jar files in the jnlp. Webstart allows to package multiple jar files.

Locked