Java noob - main() problem
Hey all :)
I've been using C for about 9 months and gotten reasonable confident in the language.. So i've now taken on Java - but when I go to compile the app it gives me an error saying I have an defined reference to main... Here's the code: Code:
class A { [ammullan@daemon ammullan]$ gcj A.java /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../crt1.o(.text+0x18): In function `_start': : undefined reference to `main' collect2: ld returned 1 exit status Simple huh (boi and I thought I knew enuf to jump straight in).... |
try making the class A public...
public class A { stuff in class A... } |
I added public to class A but I still get the undefined main problem :-(
|
that might do it...
if not use the '--main' command line argument (i think, check 'man gcj' for info) |
Kewl, it worked using --main=A :D
Bit annoying that ya have to do that tho lol :D Thanks for the help mpturner |
Try compiling with javac...I just did and it worked fine.
Doesn't work also for gcj, maybe a bug in gcj or just have to use --main |
Yeah I tried downloading the SDK last night but it crashed on me :(
Might try again tonight and then use that, although with gcj I can make binary files instead of class files :D |
try changing class A to class main
|
No that still doesn't work properly, and it shouldn't matter what you call your class, just as long as you have public block called main :D
|
All times are GMT -5. The time now is 04:52 AM. |