| | |
Newbi can anyone help with methods and classes
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi i Have written some code at Uni for two programs
this is my first one
// filename: ArrayClient.java
// Author:
// Last Updated :Jan 2005
//
// Program to demonstrate how to provide a class
// of array utilities
//
public class ArrayClient
and this is the second piece of code i have written
my problem is when i wrote them at Uni they both compiled and worked (on a mac G5)
I FTP'd them home and now only the ArrayUtilities will compile. I re-wrote the ArrayClient file and it still wont compile this is the error message i get everytime i try to compile the ArrayClient file
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:20:
cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.outputArray (tArray);
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:22: cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.resetArray (tArray);
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:24: cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.outputArray (tArray);
3 errors
Tool completed with exit code 1
can anyone point me in the right direction as to what i am doing wrong.
any help will be appreciated
this is my first one
// filename: ArrayClient.java
// Author:
// Last Updated :Jan 2005
//
// Program to demonstrate how to provide a class
// of array utilities
//
public class ArrayClient
Java Syntax (Toggle Plain Text)
{ public static void main (final String[] pArgs) { int [] tArray = new int [4]; tArray [0] = 11; tArray [1] = 22; tArray [2] = 33; tArray [3] = 44; ArrayUtilities.outputArray (tArray); ArrayUtilities.resetArray (tArray); ArrayUtilities.outputArray (tArray); } }
Java Syntax (Toggle Plain Text)
// Filename: ArrayUtilities.java // Author // Last Updated Jan 2005 // by // class that provides a number of Array Utilities // public class ArrayUtilities { // Method to reset an integer array so that // all elements have the value zero public static void resetArray (final int [] pArray) { for (int i = 0; i < pArray.length; i++) { pArray [i] = 0; } } // method to output the contents of an integer array public static void outputArray (final int [] pArray) { for (int i = 0 ; i <pArray.length; i++) { System.out.print (pArray [i] + " "); } System.out.println(); } // fliename sumArray method to add the integers of // an array together public static void sumArray (final int [] pArray) { int tSum = 0; for (int i = 0 ; i <tSum; i++) { tSum += pArray [i]; } } }
I FTP'd them home and now only the ArrayUtilities will compile. I re-wrote the ArrayClient file and it still wont compile this is the error message i get everytime i try to compile the ArrayClient file
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:20:
cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.outputArray (tArray);
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:22: cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.resetArray (tArray);
C:\Documents and Settings\Administrator\Desktop\UNI\Programming\Programming2\week1\ArrayClient.java:24: cannot resolve symbol symbol : variable ArrayUtilities location: class ArrayClient ArrayUtilities.outputArray (tArray);
3 errors
Tool completed with exit code 1
can anyone point me in the right direction as to what i am doing wrong.
any help will be appreciated
:p
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
•
•
Join Date: Jan 2005
Posts: 5
Reputation:
Solved Threads: 1
Hullo,
This looks very much like a classpath problem.
In order for the ArrayClient class to be compiled (or to run for that matter) it needs to "see" the ArrayUtilities class.
Try running:
javac -classpath . ArrayUtilities.java ArrayClient.java
to compile them. To run them try:
java -classpath . ArrayClient
Geoff
This looks very much like a classpath problem.
In order for the ArrayClient class to be compiled (or to run for that matter) it needs to "see" the ArrayUtilities class.
Try running:
javac -classpath . ArrayUtilities.java ArrayClient.java
to compile them. To run them try:
java -classpath . ArrayClient
Geoff
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I noticed that you didn't have an instance of the ArrayUtilities class in your first project. I don't have a jdk on this computer so I can't test it or I would. But to me that looks like the problem.
You could do something like this:
ArrayUtilities ar = new ArrayUtilites();
ar.resetArray(arrayname);
You could do something like this:
ArrayUtilities ar = new ArrayUtilites();
ar.resetArray(arrayname);
Well, all methods in ArrayUtilities are static so can be called without an instance.
In fact, using a call of one of them on an instance could result in a warning (depending on compiler settings).
Compiling them doesn't give any errors at all here if they're (as they should be) in the same directory.
So it's no problem in the code.
try compiling using and see what happens.
In fact, using a call of one of them on an instance could result in a warning (depending on compiler settings).
Compiling them doesn't give any errors at all here if they're (as they should be) in the same directory.
So it's no problem in the code.
try compiling using
•
•
•
•
javac -classpath . ArrayClient.java
Hi to all that have replied and thanks but i haven't got a clue as to how to do this with the program i am using to write my code. Its a program called TextPad by "helios" and has been working fine and still does on on the ArrayUtilities code.
Could any one suggest another program that is easy to set up and free to download or cheap to buy. I do have net beans but find it very confusing
I guess could have another go at that if there are no other options
Could any one suggest another program that is easy to set up and free to download or cheap to buy. I do have net beans but find it very confusing
I guess could have another go at that if there are no other options
•
•
•
•
Originally Posted by geoff.ainger
Hullo,
This looks very much like a classpath problem.
In order for the ArrayClient class to be compiled (or to run for that matter) it needs to "see" the ArrayUtilities class.
Try running:
javac -classpath . ArrayUtilities.java ArrayClient.java
to compile them. To run them try:
java -classpath . ArrayClient
Geoff
:p
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
Hi to all who replied
I have just installed NetBeans and my programs work fine
thanks to all who replied
but i had to do something i had it on my machine a while ago and took it off becasue i wasnt comfortable with it but had to do something to get my course work done.
I will probably be back as this program isnt the easiest to code in but then again i havent got a clue on any of the other languages either.

Grifflyn
I have just installed NetBeans and my programs work fine
thanks to all who replied
but i had to do something i had it on my machine a while ago and took it off becasue i wasnt comfortable with it but had to do something to get my course work done.
I will probably be back as this program isnt the easiest to code in but then again i havent got a clue on any of the other languages either.

Grifflyn
:p
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
And so you've not learned a thing...
You still don't know how to use the compiler for example, which is what was your problem in the first place.
You took the easy way out which was to install an IDE with all its wizzards to do the work for you. Next time you're somewhere where you don't have that option you'll again be lost and come here asking the exact same question all over again.
NOONE should use an IDE unless and until they can do anything it does themselves, you haven't reached that stage yet and now you likely never will.
You still don't know how to use the compiler for example, which is what was your problem in the first place.
You took the easy way out which was to install an IDE with all its wizzards to do the work for you. Next time you're somewhere where you don't have that option you'll again be lost and come here asking the exact same question all over again.
NOONE should use an IDE unless and until they can do anything it does themselves, you haven't reached that stage yet and now you likely never will.
•
•
•
•
Originally Posted by jwenting
And so you've not learned a thing...
You still don't know how to use the compiler for example, which is what was your problem in the first place.
You took the easy way out which was to install an IDE with all its wizzards to do the work for you. Next time you're somewhere where you don't have that option you'll again be lost and come here asking the exact same question all over again.
NOONE should use an IDE unless and until they can do anything it does themselves, you haven't reached that stage yet and now you likely never will.
NetBeans doesnt write the code for me i still have to think about what to write and how to get the program to work. and once i get my degree i will be usinig what ever software is avaiable to compile my programs
I do know how to use compilers but i had the problem with my machine at home and wanted a quick fix as we are under a short deadline to complete our tasks and we are set 7 per week and have to have them ready.
i didn't ask anyone to write my code for me which is cheating just how to get the programs to compile
I guess i might be looking for other forums to help with any issues i have if all i get is criticism like that and being insulted
Rgds Grifflyn
:p
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
If you worry you Die.
If you dont worry you Die.
SO DONT WORRY
:cool:
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by jwenting
And so you've not learned a thing...
You still don't know how to use the compiler for example, which is what was your problem in the first place.
You took the easy way out which was to install an IDE with all its wizzards to do the work for you. Next time you're somewhere where you don't have that option you'll again be lost and come here asking the exact same question all over again.
NOONE should use an IDE unless and until they can do anything it does themselves, you haven't reached that stage yet and now you likely never will.
grifflyn, please don't leave this forum. Jwenting is very smart and good at helping people. It's just sometimes he has a bad way of wording things that sound insulting when their not suppose to be.
![]() |
Other Threads in the Java Forum
- Previous Thread: How do i print int num1; a 5 digit number like 1 2 3 4 5
- Next Thread: updating info from other websites
Views: 4460 | Replies: 20
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component csv database detection draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linux list loop map method methods mobile netbeans newbie number object objects oracle oriented os panel print problem program programming project projects recursion replaydirector reporting researchinmotion return robot scanner score screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows






