CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2011
    Posts
    8

    Not Resolving the classpath to a file

    I am using jChats(jCharts-0.7.5.jar) application with its included example for PieChart

    If I provide the claspath to the jar file of charts ,it doesnt work,it gives me error that it is not finding particular class(in this case it is IPieChartDataSet)

    But if I extract the jar file and place the "org" folder in the current directory,it works absolutely fine

    It is also working fine with the Eclipse IDE

    Can anyone tell me what is the problem

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Not Resolving the classpath to a file

    It sounds like your not providing the correct classpath value.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Mar 2011
    Posts
    8

    Re: Not Resolving the classpath to a file

    I am providing the correct calss path i.e if it is E:\ directorty(jar file of jCharts)

    I provide the classpath i.e is E:\jCharts-0.7.5.jar

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Not Resolving the classpath to a file

    You going to have to provide a lot more information if you want us to help you. For instance:

    • The full directory path to your code
    • The full directory path to the jar file
    • The command line you are using to try to start the application
    • The command line you used to start the application when you unpacked the jar

    etc etc.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Mar 2011
    Posts
    8

    Re: Not Resolving the classpath to a file

    I have uploaded an attachment.It contains

    1>jCharts jar file

    2>Source Code and compiled class

    3> Html file to run an applet

    You just need to

    1>Set the classpath till jar and give a try and it wont work(as is mine case)

    2>Keep the extracted "org" folder in current directory it will work
    Attached Files Attached Files

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Not Resolving the classpath to a file

    Sorry but I generally don't download attachments. Can you provide the information I asked for showing the html files used to start the applet.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  7. #7
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Not Resolving the classpath to a file

    Quote Originally Posted by vin_eets View Post
    I am providing the correct calss path i.e if it is E:\ directorty(jar file of jCharts)

    I provide the classpath i.e is E:\jCharts-0.7.5.jar
    If the class is in the jar file (which it seems to be), but cannot be found, then the classpath is not correct. Simples

    Teachers open the door, but you must enter by yourself...
    Chinese proverb
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  8. #8
    Join Date
    Mar 2011
    Location
    Dunwoody GA
    Posts
    8

    Re: Not Resolving the classpath to a file

    Add "archive="jCharts-0.7.5.jar" to your applet tag.

    (i.e., <html><body><applet code="SwingDemo.class" archive="jCharts-0.7.5.jar" width='350' height='300'></applet</body></html>)

    Ray

  9. #9
    Join Date
    Mar 2011
    Posts
    8

    Re: Not Resolving the classpath to a file

    I am giving the source code and HTML file ,but you need to download the jCharts jar file to run the code

    Source Code
    ____________

    import org.jCharts.chartData.ChartDataException;
    import org.jCharts.chartData.PieChartDataSet;
    import org.jCharts.nonAxisChart.PieChart2D;
    import org.jCharts.properties.*;
    import org.jCharts.types.PieLabelType;

    import javax.swing.*;

    import java.awt.*;
    import java.awt.event.WindowEvent;
    import java.io.*;

    public class SwingDemo extends JApplet
    {

    private JPanel panel;
    PieChart2D pieChart2D;
    JButton button;
    Container con=getContentPane();
    GridBagConstraints c = new GridBagConstraints();

    public void init()
    {
    //getContentPane().add(new JButton("1"));

    con.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    button = new JButton("BarChart");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipady = 0; //reset to default
    c.weighty = 1.0; //request any extra vertical space
    c.anchor = GridBagConstraints.LINE_END; //bottom of space
    c.insets = new Insets(10,0,0,0); //top padding
    c.gridx = 1; //aligned with button 2
    c.gridwidth = 2; //2 columns wide
    c.gridy = 2; //third row


    String[] labels={"PassedTest", "FailedTest", "SkippedTest"};
    String title="Cars that Own";
    Paint[] paints={Color.green, Color.red, Color.yellow};
    double[] data={1000d, 100d, 5d};

    try{

    PieChart2DProperties pieChart2DProperties=new PieChart2DProperties();
    pieChart2DProperties.setPieLabelType(PieLabelType.LEGEND_LABELS);
    pieChart2DProperties.setPieLabelType( PieLabelType.VALUE_LABELS );

    PieChartDataSet pieChartDataSet=new PieChartDataSet( title, data, labels, paints, pieChart2DProperties );

    pieChart2D=new PieChart2D( pieChartDataSet, new LegendProperties(), new ChartProperties(), 300, 250 );
    }catch(Exception e){}

    }


    public void paint(Graphics g){
    try{

    pieChart2D.setGraphics2D( (Graphics2D) this.getContentPane().getGraphics() );
    pieChart2D.render();
    con.add(button, c);
    }catch(Exception e){}
    }







    }

    HTML FILE
    _________

    <html><body><applet code="SwingDemo.class" width='350' height='300'></applet</body></html>


    I use appletviewer "XXX".html where XXX is html file name or directly run the HTML file
    I have also tried tunning apletviewer SwingDemo.java.It doesnt even work


    "dlorde" :What classpath should I give if it is the problem of classpath because according to me ,I am providing correct classpath

    * The full directory path to your code
    My code and class file is in C:\ drive

    * The full directory path to the jar file
    Jar file is in E:\jChatrs thus I set the enviorment variable path to E:\jChatrs\jCharts-0.7.5.jar
    * The command line you are using to try to start the application
    I usually run the HTML file or appletviewer XXX.html

    * The command line you used to start the application when you unpacked the jar
    I usually run the HTML file or appletviewer XXX.htm
    Last edited by vin_eets; April 7th, 2011 at 12:03 AM.

  10. #10
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Not Resolving the classpath to a file

    Quote Originally Posted by vin_eets View Post
    "dlorde" :What classpath should I give if it is the problem of classpath because according to me ,I am providing correct classpath
    You should provide the classpath to the jar file.

    * The full directory path to the jar file
    Jar file is in E:\jChatrs thus I set the enviorment variable path to E:\jChatrs\jCharts-0.7.5.jar
    The environment variable 'path' is the OS executables directory list, not the Java application classpath, which is called 'classpath'.

    However, the applet classpath is set using the 'archive' tag as Ray Newman explained previously.

    You should be aware that for security reasons, applets are restricted in what they can do, and the applet's class loader can read only from the same codebase from which the applet was started.

    This means that archives in archiveList must be in the same directory as, or in a subdirectory of, the codebase. Entries in archiveList of the form ../a/b.jar will not work unless explicitly allowed for in the security policy file (except in the case of an http codebase, where archives in archiveList must be from the same host as the codebase, but can have ".."'s in their paths.). See The Applet Tag.

    For this reason, applets requiring additional libraries are usually packaged in a jar - see Running Jar-packaged Software.

    You may find the Java Tutorial on Deploying Applets useful, particularly Deploying with the Applet tag.

    The truth is, when all is said and done, one does not teach a subject, one teaches a student how to learn it. Teaching may look like administering a dose, but even a dose must be worked on by the body if it is to cure. Each individual must cure his or her own ignorance...
    J. Barzun
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured