Getting a "cannot access package" error...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blazedaces
    Contributor
    • May 2007
    • 284

    Getting a "cannot access package" error...

    Hello, it's been a while since I posted on these forums. My issue I think isn't as much in my code as it's in the syntax and structure in references other packages. I'll get straight to it then:

    There's a package called "randomX" which, while I don't know if you care to know, has a program that accesses a site called hotbits to produce true random numbers based on radioactive decay. You can look it up if you're any interested.

    Anyway, so I'll post the relevant code and errors here:

    [code=java]/**
    * @(#)MakeRandomA lphaNumerics.ja va
    *
    *
    * @author
    * @version 1.00 2008/6/5
    */

    import java.util.*;
    import randomX.*;

    public class MakeRandomAlpha Numerics {
    private static int lengthOfCode = 8;
    private randomX.randomH otBits random = new randomX.randomH otBits();
    ...[/code]

    Code:
    Error message appears at line 14: cannot access randomX
    Now the folder which this file is contained within contains the package file (a folder named randomX, inside of which is the class files for randomX and randomHotBits.

    I'm not 100% sure on the way the structure of files is supposed to work to ensure java finds the correct classes. I tried adding the location of that randomX package folder to the class path, but that didn't do the trick.

    I thought perhaps it was looking at the randomX file contained in the folder, so I removed it, but then it said it couldn't find the randomHotBits program (with a similar looking error message). I even tried removing just randomX. These seem like silly solutions and I'm just grabbing at straws at this point...

    Any and all help is very much appreciated, thanks,

    -blazed

    Edit: I just looked at the build output (I'm using JCreator) and saw this more elaborate error message, perhaps it'll help:

    Code:
    --------------------Configuration: <Default>--------------------
    C:\programs\randomPrograms\MakeRandomAlphaNumerics.java:14: cannot access randomX
    bad class file: C:\programs\randomPrograms\randomX\randomX.class
    class file contains wrong class: randomX.randomX
    Please remove or make sure it appears in the correct subdirectory of the classpath.
        private randomX.randomHotBits random = new randomX.randomHotBits();
                    ^
    1 error
    
    Process completed.
  • blazedaces
    Contributor
    • May 2007
    • 284

    #2
    Sorry guys, seems I've found the answer...

    Instead of import randomX.* I was supposed to be even more specific and import randomX.randomH otBits as well...

    Reason being that just like how if you import the java.* package you're not importing the java.util.* packages...

    That was very frustrating...

    -blazed

    Comment

    • Dököll
      Recognized Expert Top Contributor
      • Nov 2006
      • 2379

      #3
      Originally posted by blazedaces
      Sorry guys, seems I've found the answer...

      Instead of import randomX.* I was supposed to be even more specific and import randomX.randomH otBits as well...

      Reason being that just like how if you import the java.* package you're not importing the java.util.* packages...

      That was very frustrating...

      -blazed
      Good you found it, frustrated me also some time ago:-) Thanks for letting us know...

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by blazedaces
        Hello, it's been a while since I posted on these forums. ...[/code]
        Welcome back. Hope you won't disappear again.


        P.S So where were you? Kidnapped by terrorists?

        Comment

        Working...