Re: Simple Java Problem
From: Liz (liz_at_XXXXzylanid.demon.co.uk)
Date: 08/15/04
- Next message: thufir.hawat_at_mail.com: "Re: newbie help interpreting this code from book"
- Previous message: John: "Re: Simple Java Problem"
- In reply to: John: "Re: Simple Java Problem"
- Next in thread: John: "Re: Simple Java Problem"
- Reply: John: "Re: Simple Java Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 15 Aug 2004 10:11:16 +0100
Hi John
I have copied and pasted your classes, and they work just fine on my
PC (once the dice/aDice error is corrected as someone pointed out
already).
When you compile the DiceCon.java file, is the folder that contains it
(and Dice.java) your current folder? Or have you moved to the folder
with javac.exe in? My setup is to run a batch file when I want to use
java in the cmd console; the batch file changes the path so that the
javac.exe file will be found automatically, whichever folder I am
currently in. If you don't do that, you have to address you files by
their folder names all the time, and (as in your case) the classes
cannot "see" one another. In case this is your problem, my batch file
looks like this (you will have to adapt it):
-----------------------------
@echo off
c:
cd\
cd jdk1.3.1
path = %path%;c:\jdk1.3.1\bin
echo path set
echo use edit CName.java
echo use javac CName.java
echo use java CName
echo use edit HName.html
echo use appletViewer HName.html
doskey /insert
-----------------------------------
hth
Liz
On Sun, 15 Aug 2004 09:29:16 GMT, John wrote:
>Hi Paul, thanks for ur advice, when i put all the code into one class it
>works perfectly like you advised but when i split it into 2 seperate classes
>it doesnt work. in my original version, the Dice class compliles correctly
>whereas the DiceCon class wont compile i get 2 error messages saying it
>doesnt recognised the Dice Class. Im compiling and running from the command
>line. The 'arrows' highlight where the error is. The error message is
>"cannot resolve symbol: class Dice, location :class DiceCon,
>
>Dice aDice = new Dice(3);
>
>Both source files are contained in a single folder . I think the problem is
>as you said, in that both source files are not visible to each other. Im
>not sure exactly how to make them see each other, (do i have to include
>code in the DiceCon class to make a reference to where to look for the Dice
>Class?), the only time ive used classes is in C++ and that was in an IDE
>enviroment . (Borland) and that was simple enough using header files.
>
>
>
>"Paul Lutus" <nospam@nosite.zzz> wrote in message
>news:10hu05kqbq72h23@corp.supernews.com...
>> John wrote:
>>
>> > hi hal, thanks for ur advice, ive been up all night and ive figured out
>> > that problem which uve mentioned but i still get 2 error messages which
>> > relate to the line of code
>> >
>> > Dice aDice = new Dice(3);
>> >
>> > i get arrows under the word 'Dice' in each of the above instances of the
>> > word 'Dice' in the code above.
>>
>> Arrows? What error message? Are you sure both source files and both class
>> files are visible to each other? I ask this because it sounds like your
>> DiceCon class cannot see the Dice class.
>>
>> For simplicity's sake, put the "main" method plus the test code into the
>> Dice class, thus making one class for testing purposes. After you have
>> gotten the program compiling and running correctly, you can split into two
>> classes again, and deal with that issue separately.
>>
>> You haven't said how you are compiling or running your program. If you are
>> using a development environment, say so. If you are compiling and running
>> from the command line, say so. Give the details for either case.
>>
>> --
>> Paul Lutus
>> http://www.arachnoid.com
>>
>
-- Liz Hanson
- Next message: thufir.hawat_at_mail.com: "Re: newbie help interpreting this code from book"
- Previous message: John: "Re: Simple Java Problem"
- In reply to: John: "Re: Simple Java Problem"
- Next in thread: John: "Re: Simple Java Problem"
- Reply: John: "Re: Simple Java Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|