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

{
	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);

	}
}

and this is the second piece of code i have written

// 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];
			}
	}


}

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

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

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);

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

javac -classpath . ArrayClient.java

and see what happens.

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

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

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. :D :D

Grifflyn

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.

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.

If i were a younger student i would accept criticism like that but being a 36 year old mature student i know that constructive criticism is better than in effects calling some one a cheat and a slacker.
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
:sad:

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.

I don't think he meant it in a bad way. I have to say I agree. I started out learning vb.net and used visual studio.net as an IDE. When I switched to java I was a very lazy programmer because I has such a good IDE to use in vb.net. You would be suprised at how much you learn using the command line to compile and run your programs. Actually, I've got so use to it that I don't like using IDE. I simply like using a good Value Added Text Editor like jEdit to program in.

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.

If your a student at school then you probably can't help what they use, and they probably use an IDE like textpad. I have the same problem, but you have to use whatever they tell you too.

I simply like using a good Value Added Text Editor like jEdit to program in.

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.

I understand what you are saying and TextPad is a text editor similar to jEdit.

At Uni, we are coding on a Mac G5 with the standard text editor so I do have an idea of how to use the command line to compile and run my programs. I initially purchased TextPad to help me write Xhtml and found the colour syntax highlighting a valuable tool for placing tags and stuff.
When I delved into the help file and found out that I could code java with it as well, I thought I would use it for writing my java and it has been a great help to me. :rolleyes:
when I first started I did try to use NetBeans and didn't get on with it at all and still don’t but it helped me compile the 2 files and showed me that it wasn't my coding. I will keep on my machine but wont code init. It isn't the most user-friendly program for a beginner

I am guessing but are you saying rather than using the compile icon on the GUI I should be using the command prompt and javac my files that way?
If yes then I will have to try to figure out how to do it. As you said I got lazy, there was a button to use so I used it

I will stay with DaniWeb because when I first started out on this Java endeavor it was a great help and still is. So thanks for your help.
I will be back with more questions and requests for help as and when I need it, which will probably be quiet regular as I am really struggling with this subject
:o

I didn't say you aren't willing to learn, just that you took the easy way out which means you didn't learn anything...

If you'd taken the time to set up your commandline properly (just a few minutes work) you'd have been up and running in no time.

Glad to hear your staying. I think it would be a good idea to set up the environment variables and stuff like that to use the command line. You'll learn a lot from it. This doesn't mean you have to stay with it forever though. Once you learn how java compiles and runs programs and stuff like that, you can switch back to the IDE. Setting up the environment variables are a trivial thing if you've never done it before. I can help you with this if you like. Also, you said you purchased textpad. You can get free ones off the net that most people like considerably better. But it's all a matter of opinion.

What about ViM?

http://www.vim.org/

The interface is a little cryptic at first, but it was pretty good syntax highlighting. When I need to do any coding or scripting, I usually fire that up. It works for Mac, Linux, PC, DOS... pretty much any platform you'll encounter.

VI is excellent. It's my default lightweight editor (not in the least because I do a lot of work remote at customer sites and our own Unix servers where all I have is a terminal window).

I didn't say you aren't willing to learn, just that you took the easy way out which means you didn't learn anything...

If you'd taken the time to set up your commandline properly (just a few minutes work) you'd have been up and running in no time.

jwenting
:eek:
ok so now i am stuck i tried looking for my class path and i ran

echo %CLASSPATH%

and it came back with this.

Is this correct

"C:\Program Files\\Java|J2re1.4.2_05\Lib\extQTJava.zip"

if not could you suggest how to set my classpath so that i compile from the command prompt because at the moment i cant even compile from there.
Please accept my appologies if i seemed a bit short in some of my replys but this Uni thing is stressing me because i dont just have to contend with java and after being out of education for some time its a lot different

what should my classpath actualy look like

Thanks in Advance Grifflyn

Here is my classpath: Note: Your's will probably be different.

.;%classpath%.;.;C\Program Files\Java\jdk1.5.0\lib\tools.jar

classpath should point to the tools.jar file


Here is what my path variable looks like:

C:\Program Files\Java\jdk1.5.0\bin


it just points to the bin folder.


Note: to set your environment variable, right click on the my computer icon, then select advanced, then at the bottom there will be something that says environment variables.

Here is my classpath: Note: Your's will probably be different.

.;%classpath%.;.;C\Program Files\Java\jdk1.5.0\lib\tools.jar

classpath should point to the tools.jar file


Here is what my path variable looks like:

C:\Program Files\Java\jdk1.5.0\bin


it just points to the bin folder.


Note: to set your environment variable, right click on the my computer icon, then select advanced, then at the bottom there will be something that says environment variables.

Thanks for that the problem is solved I set the path to J2sdk which didn't work. Then was advised by one of the PHd students to uninstall SDK and re-install it which worked. She also used TextPad as her editr so now i have the path set and it works in the DOS prompt as well as Textpad i will be using the text pad editor

thanks for your help though

Grifflyn

This article has been dead for over six months. Start a new discussion instead.