Results 1 to 11 of 11
  1. #1
    Jackount is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Unhappy This is an error? public static void main(String args[])

    This is my code written in Eclipse:
    Java Code:
    class apples{
    	public static void main(String args[]){
    		System.out.println("Hello");
    	}
    }
    This cannot be executed as it contains an error? I have it from the Java programming tutorials on youtube from 2009 (YouTube - ‪Java Programming Tutorial - 5 - Variables‬‏)
    Why? I suppose Java has been updated and has to be written differently?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  3. #3
    billycro is offline Member
    Join Date
    Sep 2010
    Posts
    9
    Rep Power
    0

    Default

    move the square brackets no?

    bc the data type of args is a String[], so try that? or does it work both ways....hmm

  4. #4
    gauravmanral's Avatar
    gauravmanral is offline Gaurav Manral
    Join Date
    Jul 2011
    Location
    Delhi
    Posts
    37
    Rep Power
    0

    Default

    this is the error

    Exception in thread "main" java.lang.NoClassDeffoundError:

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by billycro View Post
    move the square brackets no?

    bc the data type of args is a String[], so try that? or does it work both ways....hmm
    @ billycro: no, this doesn't matter.

    @ guaravmanral: is that the complete error message or is there more? Is your Java class named the same as the file name?

  6. #6
    gauravmanral's Avatar
    gauravmanral is offline Gaurav Manral
    Join Date
    Jul 2011
    Location
    Delhi
    Posts
    37
    Rep Power
    0

    Default

    @ Fubarable: yes, this is followed by classname.

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    What Fubar was asking was your class is called apples. Is it saved in apples.java?

    Also do you compile it with javac apples.java? Do you run it with java apples?

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default

    Copy and paste the error message. All of it.

    db

  9. #9
    gauravmanral's Avatar
    gauravmanral is offline Gaurav Manral
    Join Date
    Jul 2011
    Location
    Delhi
    Posts
    37
    Rep Power
    0

    Default

    i did the same what u r saying. still, it's compiles but don't run.

  10. #10
    cucucur is offline Member
    Join Date
    Apr 2011
    Posts
    20
    Rep Power
    0

    Default

    maybe the classpath? have you checked it?

  11. #11
    gauravmanral's Avatar
    gauravmanral is offline Gaurav Manral
    Join Date
    Jul 2011
    Location
    Delhi
    Posts
    37
    Rep Power
    0

Similar Threads

  1. What wrong with it?case : public static void main
    By bytescode in forum New To Java
    Replies: 7
    Last Post: 02-10-2011, 08:01 AM
  2. Replies: 1
    Last Post: 12-04-2010, 06:41 PM
  3. Public static void main (String args[])
    By arefeh in forum New To Java
    Replies: 12
    Last Post: 01-28-2010, 12:58 PM
  4. Replies: 9
    Last Post: 11-23-2008, 12:03 AM
  5. Replies: 5
    Last Post: 10-06-2008, 01:11 AM

Posting Permissions

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