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.
OK, I think I got that part, I used: import histogramData.*; And NetBeans now seems to know where it is.
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.
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.
No, I just started saying histogramData, so to reduce confusion, I kept using that. The class is HistogramData.class.
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?
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.
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();
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 } */ }
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.
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.
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?
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\.
Is there anything in the area circled in that picture, that will tell you what package it belongs to.
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.