Results 1 to 5 of 5

Thread: new to Java

  1. #1
    holtaf is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default new to Java

    Hey guys .I'm just today turned to Java.I'm using GCJ compiler , and today I wrote my first program wich isn't compiling .
    This is my source code
    1 public class main {
    2
    3 public static void main( String []args) {
    4
    5
    6
    7 }
    8
    9 }


    and the output is following

    root@linux-machine:/home/arthur/java# gcj main.java
    main.java:3: warning: This method has a constructor name
    public static void main( String []args) {
    ^^^^^^^^^^^^^^^^^^^^
    1 problem (1 warning)
    /usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
    (.text+0x18): undefined reference to `main'
    collect2: ld returned 1 exit status


    P.S. sorry for my bad english it's not my native language :)

    Any help will be greatly appreciated!
    -holtaf

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I'm not sure what gcj is but I suggest you download the sdk(or Jdk always get them mixed up) and use javac.

  3. #3
    holtaf is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default

    GCJ is GNU Compiler for Java
    Now i'm downloading eclipse

  4. #4
    holtaf is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default

    GCJ is GNU Compiler for Java
    Now i'm downloading eclipse

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    Even though this would work with Oracle Java, it's because "main" is a very poor name for a class since it clashes with the main() method.
    The regular JVM can handle it, but it's still poor.

    Besides, classnames should start with a capital letter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •