how to add jar file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikassawant
    New Member
    • Mar 2009
    • 27

    how to add jar file

    hi,
    to solve problem of Importing excel file in to JTable,I used
    JTableReadTable ModelTask class.
    This class in not present in jdk version. Thats why I download one jar file named as...
    datagrid-all.jar.

    In enviornment variables,I set the classpath as
    C:\datagrid\dat agrid-all.jar

    Now also my project give error as Can not find Class Symbol.

    Is here any mistake to set the path.


    Thanks,in advance.

    Regards,
    Vikas Sawant.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    How are you compiling the source files?

    Comment

    • vikassawant
      New Member
      • Mar 2009
      • 27

      #3
      Thanks for reply.

      I am using Editor-JCreator and there is buttons for compilation and execution,which I used.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Basically you need to tell your editor to use that jar as part of classpath when executing the javac command. How to do that may be documented in Jcreator's help (I don't use it and I don't know). If you can't find how you can always compile the files on the command line and provide the classpath yourself.

        Comment

        • vikassawant
          New Member
          • Mar 2009
          • 27

          #5
          yes I make this modification.It works.My code for importing excel file is,

          try {
          String excelFileName = "Team1.xls" ;
          File file = new File(excelFileN ame ); //‘file’ is the file you want to load.
          JProgressBar progressBar = new JProgressBar(); //‘progressB ar’ will show how much data it have loaded.
          JTableReadTable ModelTask task = new JTableReadTable ModelTask(file, null,progressBa r,model);
          task.execute();
          }
          catch (IOException ex) {
          System.out.prin tln(ex.getMessa ge());
          ex.printStackTr ace();
          }

          but now it gives error that is,

          D:\flb\Manual.j ava:1023: cannot find symbol
          symbol : constructor JTableReadTable ModelTask(java. io.File,<nullty pe>,javax.swing .JProgressBar,j avax.swing.tabl e.DefaultTableM odel)
          location: class com.zfqjava.swi ng.JTableReadTa bleModelTask
          JTableReadTable ModelTask task = new JTableReadTable ModelTask(file, null,progressBa r,model);


          What is the reason behind this error.

          Thanks.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            See the error message. It's trying to hard to tell what the problem is.
            Basically that the JTableReadTable ModelTask class does not have a constructor with parameters which match the arguments that you are passing when calling that constructor.

            Comment

            • vikassawant
              New Member
              • Mar 2009
              • 27

              #7
              This is the constructor definition which i get from API ,

              public JTableReadTable ModelTask(Objec t urlObject,
              Map readProperties,
              JProgressBar progressBar,
              JTable table)

              Parameters:
              urlObject - a java.io.File or java.net.URL object
              readProperties - ModelIO
              progressBar - a progress bar to monitor the read process
              table - the result TableModel will set to JTable


              please tell me what is wrong in my constructor.

              Thanks,
              Vikas Sawant

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                The error message that you got is telling you that you are passing a
                javax.swing.tab le.DefaultTable Model where a JTable is expected.

                Comment

                Working...