classpath error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • giantfatiguana
    New Member
    • Jul 2008
    • 5

    classpath error

    hey all im a beginner java user and am getting an error relating to the classpath i assume.

    I have a file JM550b.java which is trying to access the class QTCycle when compiling. QTCycle.java creates a package called jmqt "package jmqt;" and the class is placed in that folder.

    QTCycle.java compiles successfuly but when i try to compile JM550b.java i get an error saying "cannot access QTCycle" on the line "private static QTCycle player;"

    It also says

    "cannot access QTCycle
    bad class file: C:\Documents and Settings\Rachae l\Desktop\Dom\T utorial\jmqt\QT Cycle.class
    class file contains wrong class: jmqt.QTCycle
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    private static QTCycle player;"

    My directory is like this: (im sure this is where the problems arise please help me im struggling with this!)
    Desktop\Dom\Tut orial\src - this is where the main .java files of my project are kept as there a few classes the main program will access.
    Desktop\Dom\Tut orial\jmqt - this is where the QTCycle class goes when it is compiled

    Im not sure what more i need to say but if anyone can help i will be glad to give all info i can.

    Please help!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Your first error is caused by trying to access a private field from nother class. That's not allowed.

    Comment

    • giantfatiguana
      New Member
      • Jul 2008
      • 5

      #3
      Originally posted by r035198x
      Your first error is caused by trying to access a private field from nother class. That's not allowed.
      But i have other lines similar such as "private static Button start, stop;"
      and "private static EightBeat1 pat;"

      These two work fine.

      Thank you for reply :)

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        I see now that I did not understand your initial statements, sorry.
        It should be a directory structure problem. Your jmqt folder must be in the src folder.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          This is where your class is stored:

          Settings\Rachae l\Desktop\Dom\T utorial\jmqt\QT Cycle .class

          The class seems to be in the package 'jmqt', can you show us the classpath
          you used?

          kind regards,

          Jos

          Comment

          • giantfatiguana
            New Member
            • Jul 2008
            • 5

            #6
            Originally posted by JosAH
            This is where your class is stored:

            Settings\Rachae l\Desktop\Dom\T utorial\jmqt\QT Cycle .class

            The class seems to be in the package 'jmqt', can you show us the classpath
            you used?

            kind regards,

            Jos
            by classpath do you mean under project settings? im using jcreator

            would this seem right?

            C:\Documents and Settings\Rachae l\Desktop\Dom\T utorial;C:\jmus ic\jmusic.jar;C :\WINDOWS\syste m32\QTJava.zip; C:\Documents and Settings\Rachae l\Desktop\Dom\T utorial\jmqt;C: \Documents and Settings\Rachae l\Desktop\Dom\T utorial\QTCycle ;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \rt.jar;C:\Prog ram Files\Java\jdk1 .6.0_06\lib\dt. jar;C:\Program Files\Java\jdk1 .6.0_06\lib\too ls.jar;C:\Progr am Files\Java\jdk1 .6.0_06\jre\lib \ext\dnsns.jar; C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\localedata .jar;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\sunjce_pro vider.jar;C:\Pr ogram Files\Java\jdk1 .6.0_06\jre\lib \ext\sunmscapi. jar;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\sunpkcs11. jar

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by giantfatiguana
              by classpath do you mean under project settings? im using jcreator

              would this seem right?

              C:\Documents and Settings\Rachae l\Desktop\Dom\T utorial;C:\jmus ic\jmusic.jar;C :\WINDOWS\syste m32\QTJava.zip;C:\Documents and Settings\Rachae l\Desktop\Dom\T utorial\jmqt;C: \Documents and Settings\Rachae l\Desktop\Dom\T utorial\QTCycle;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \rt.jar;C:\Prog ram Files\Java\jdk1 .6.0_06\lib\dt. jar;C:\Program Files\Java\jdk1 .6.0_06\lib\too ls.jar;C:\Progr am Files\Java\jdk1 .6.0_06\jre\lib \ext\dnsns.jar; C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\localedata .jar;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\sunjce_pro vider.jar;C:\Pr ogram Files\Java\jdk1 .6.0_06\jre\lib \ext\sunmscapi. jar;C:\Program Files\Java\jdk1 .6.0_06\jre\lib \ext\sunpkcs11. jar
              I boldfaced the suspicious classpath elements; there's more trash in there: those
              paths leading to the private jre (that comes with the jdk) shouldn't be there,
              neither anything in the jre's ext directories should be there. If I were you I'd clean
              that mess up a bit, remove and recompile that class and try again.

              kind regards,

              Jos

              Comment

              • giantfatiguana
                New Member
                • Jul 2008
                • 5

                #8
                Originally posted by JosAH
                I boldfaced the suspicious classpath elements; there's more trash in there: those
                paths leading to the private jre (that comes with the jdk) shouldn't be there,
                neither anything in the jre's ext directories should be there. If I were you I'd clean
                that mess up a bit, remove and recompile that class and try again.

                kind regards,

                Jos
                im sorry i misunderstood you, do you mean to remove the C:\Program Files\Java\jdk1 .6.0_06\jre\lib \rt.jar; and any others under \jre ?

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Originally posted by giantfatiguana
                  im sorry i misunderstood you, do you mean to remove the C:\Program Files\Java\jdk1 .6.0_06\jre\lib \rt.jar; and any others under \jre ?
                  The JDK comes with its own private JRE and on top of that it comes with a public
                  JRE. The first JRE is none of our business, i.e. it is used by the development
                  tools such as javac, jar etc. Have a look in your C:\Program Files\Java directory:
                  you'll find a JDK directory and a JRE directory; that JRE directory is the public
                  JRE; that private JRE is a subdirectory of the JDK directory. There is no need
                  to have a classpath component point to any JRE directory at all. Your classpath
                  however is full of it; get rid of them, they're useless.

                  kind regards,

                  Jos

                  Comment

                  • giantfatiguana
                    New Member
                    • Jul 2008
                    • 5

                    #10
                    Originally posted by JosAH
                    The JDK comes with its own private JRE and on top of that it comes with a public
                    JRE. The first JRE is none of our business, i.e. it is used by the development
                    tools such as javac, jar etc. Have a look in your C:\Program Files\Java directory:
                    you'll find a JDK directory and a JRE directory; that JRE directory is the public
                    JRE; that private JRE is a subdirectory of the JDK directory. There is no need
                    to have a classpath component point to any JRE directory at all. Your classpath
                    however is full of it; get rid of them, they're useless.

                    kind regards,

                    Jos
                    Okay thank you very much for you help and sorry to bother you with what was probably a trivial question. I got so frustrated that i just removed QTCycle completely and have managed to function without it.

                    Thanks again!

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by giantfatiguana
                      Okay thank you very much for you help and sorry to bother you with what was probably a trivial question. I got so frustrated that i just removed QTCycle completely and have managed to function without it.

                      Thanks again!
                      That's the old Roman way of curing someone: amputation. You have basically
                      'unsolved' your problem which basically was a classpath problem. Better clean
                      up that classpath list before you're going to use packages again because that
                      problem will surely rear its ugly head again in the near future.

                      kind regards,

                      Jos

                      Comment

                      Working...