1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Any Java developers out there?

Discussion in 'BBS Hangout' started by GladiatoRowdy, Sep 27, 2007.

  1. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    I have an HTML file that is in the same format as the Java documentation, it says that histogramData is a class that extends java.lang.Object. It has two methods, main and getInputData. I am trying to use the getInputData method to retrieve an array of integers that I need to then sort (using the array.sort object), manipulate, and then graph.;

    I am using NetBeans.
     
  2. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    OK, I think I got that part, I used:

    import histogramData.*;

    And NetBeans now seems to know where it is.
     
  3. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    Heh. Sorry guys. I offered to help, and then promptly forgot to check this thread again after I went home for the day.

    Sounds like you got it figured out.
     
  4. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    Never mind, it says that the package does not exist.

    Any help?
     
  5. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    Try placing the histogramData.class file in the same directory as your program to see if it works then.

    Also, does the file really start with a lowercase h, that goes against one of the most basic conventions, I'd hope a teacher would do better than that.
     
  6. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    No, I just started saying histogramData, so to reduce confusion, I kept using that. The class is HistogramData.class.
     
  7. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    Alright, so what error exactly are you getting? Are you getting the Reference Problems pop-up box? Can you right-click your project and select Resolve Reference Problems?
     
  8. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    I put the HistogramData.class file in the same directory as the histogram.java program that I am writing and the compiler still doesn't seem to be able to find it.
     
  9. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    Can you post the code that you have so far?
     
  10. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    Cannot find symbol
    symbol class HistogramData
    location class histogram.Histogram

    Then, the message repeats. That is when I hover over this line, which is underlined in red:

    HistogramData dataPoints = new HistogramData();
     
  11. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    Everything below the main method is currently commented out since I cannot get the data out of the instructor provided class.

    /*
    * Main.java
    * Created on September 27, 2007, 11:11 AM
    * By Andrew Moon for CSCI 3134.01
    */
    package Histogram;
    import java.util.*;

    public class Histogram extends java.lang.Object {

    /** Creates a new instance of Main */
    public Histogram() {

    }

    public static void main(String[] args) {
    HistogramData dataPoints = new HistogramData();
    int histogramDataPoints [] = dataPoints.getInputData();
    Arrays.sort(histogramDataPoints);
    System.out.println(histogramDataPoints);
    }
    /*
    public static int getMax(){
    //Identifies and returns largest value in the array
    int maxValue = histogramPointsSorted[histogramPoints.count-1];
    return maxValue;
    }

    public static float getMiddlePoint(){
    //Identifies and returns the median value in the array

    }

    public static int getMin(){
    //Identifies and returns the smallest value in the array
    int minValue = histogramPointsSorted[0];
    return minValue;
    }

    public static int getNumberOfDataPoints(){
    //Returns the number of data points in the array
    int numOfDataPoints = histogramPoints.count;
    }

    public static void graphIt(){
    //Graphs the histogram
    }

    public static void setDefaultDataPoints(){
    //Sets the data points from the histogramData class' getInputData() method
    }

    public static void setEchoCharacter(char echoCharacter){
    //Sets the echo character for the graph
    if (echoCharacter != "*" and echoCharacter != "." and echoCharacter != "#"){

    }
    }

    public static void setName(){
    //Sets a name for the histogram
    }

    public static void setOutputContainer(){
    //Sets the container type to be used to output the histogram
    } */
    }
     
  12. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    Ah, so your Histogram class is in package Histogram. Because then it should be put at c:\Program Files\Java\Histogram\Histogram.java and HistogramData.class should be in c:\Program Files\Java. Your classpath should be c:\Program Files\Java as well.
     
  13. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    This is assuming HistogramData is not in a package which you should be able to tell by looking at the accompanying .html file.

    Hmm, I can't edit. I didn't know I could get demoted from Contributing Member to Member.
     
  14. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    On the JavaDoc (HTML file) for the HistogramData class does it say if it's in a package? It should be just above the heading for the page.

    I'm not familiar with NetBeans, but does it have it's own classpath for the project and is the original location of the HistogramData file included in that? Or does it just use your system classpath?
     
  15. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    The JavaDoc has "Package Class Tree Deprecated..." at the top and "Class" is selected.
     
  16. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    As far as I know, it uses the system and user variables, the system variable is set to the program files\java folder and I have a personal one set to c:\users\aamoon\.
     
  17. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    [​IMG]

    Is there anything in the area circled in that picture, that will tell you what package it belongs to.
     
  18. pradaxpimp

    pradaxpimp Member

    Joined:
    Aug 3, 2002
    Messages:
    5,025
    Likes Received:
    71
    Cooper?
     
  19. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    No, there is nothing between the horizontal rule at the top and "Class HistogramData"
     
  20. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    Remove the "package Histogram;" line from your code.

    According to the HTML file you're talking about, which is the JavaDoc, the class that your teacher provided is NOT part of a package. (if it did, it would have something like org.something.HistogramData) Since no package is defined for that class, it's part of what they call the "default package".

    In your code, you put "package Histogram" at the top of your class, which means your class Histogram is part of the named package Histogram.

    However, unless I'm mistaken, you cannot use a class that is part of the default package from a named package.

    So, if you get rid of the line "package Histogram;" from your code, it will make your class become a member of the "default package", and you should be good to go.


    I think.

    :)
     

Share This Page