| Author |
Problem Creating instances in Java
|
|
| carlito@whitmore.fsnet.co.uk 2006-02-22, 9:57 pm |
| Hi guys can anyone help im at my wits end with this.
i have many java programs on my computer that i have done in the past
and they all have worked fine. But!!! now i have a problem creating
instances of other classes for example:
Convert con = new Convert();
does not work. it says Cannot identify symbol Convert. But i know for a
fact the class Convert is compiled and also is in same directory.
Every time i try and compile a program it does not like any instance
methods.
(with all java files on my computer);
Many thanks
Andrew
| |
| Hal Rosser 2006-02-22, 9:57 pm |
|
<carlito@whitmore.fsnet.co.uk> wrote in message
news:1140658929.449640.32150@f14g2000cwb.googlegroups.com...
> Hi guys can anyone help im at my wits end with this.
>
> i have many java programs on my computer that i have done in the past
> and they all have worked fine. But!!! now i have a problem creating
> instances of other classes for example:
>
> Convert con = new Convert();
>
> does not work. it says Cannot identify symbol Convert. But i know for a
> fact the class Convert is compiled and also is in same directory.
>
> Every time i try and compile a program it does not like any instance
> methods.
> (with all java files on my computer);
If you create a Convert constructor which accepts an arg - and you did not
create a no-arg constructor, that error will occur. Java provides the
no-arg constructor free of charge, unless you create a constructor - in
which case the no-arg constructor is -not- provided.
| |
| carlito@whitmore.fsnet.co.uk 2006-02-23, 3:57 am |
| actually my class Convert has a contructor with one argument. and i
call instance as follows
Convert con = new Convert(temp);
however when i compile from the command line it will not compile but if
i use a program such as netbeans or JCreate it compiles.
I dont understand why though
Cheers
| |
|
|
| Roedy Green 2006-02-23, 3:57 am |
| On Wed, 22 Feb 2006 21:58:59 -0500, "Hal Rosser"
<hmrosser@bellsouth.net> wrote, quoted or indirectly quoted someone
who said :
>If you create a Convert constructor which accepts an arg - and you did not
>create a no-arg constructor, that error will occur. Java provides the
>no-arg constructor free of charge, unless you create a constructor - in
>which case the no-arg constructor is -not- provided.
see http://mindprod.com/jgloss/gotchas.html#CONSTRUCTOR
You might check out the other gotchas lying in wait for you while you
are there.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
| |
|
|
| carlito@whitmore.fsnet.co.uk 2006-02-23, 7:03 pm |
| Thanks Guys everything really helped i have subsequently fixed the
problem.
The problem was that when setting my classpath i did not include
working directory as follows:
Classpath = C:\SomeFolder;C:\SomeOtherFolder\Some.jar; . ;
I needed to include the dot to include working dir
Cheers Again
Andrew
|
|
|
|