Page 2 of 2 FirstFirst 12
Results 21 to 28 of 28
  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    Yes.
    But when you execute the main class you are executing from the directory that contains that folder...or your -cp flag references the folder containing javaapplication10.

    And then the command is"java javaapplication10.Main".

    All the rest of your flailing around in the class has mucked things up...the classes were fine, it was a mixture of your command and where you were running it from.

  2. #22
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by madsovenielsen View Post
    As i understand packages. after reading these tutorials:

    Java - Packages
    The Java Package Tutorial

    A package is just a folder that contains the files. in my situation: javaapplication10

    And yes the folder exists. :)
    But one class is in the javaapplication10.Main package and the other one is in package javaapplication10.say; they don't belong in the same directory; the directory structure should be as follows:

    X/javaapplication10/Main/Main.class
    X/javaapplication10/say/say.class

    Your classpath should point to X and your main class should be run as: application10.Main.Main

    kind regards,

    Jos

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    Quote Originally Posted by JosAH View Post
    But one class is in the javaapplication10.Main package and the other one is in package javaapplication10.say; they don't belong in the same directory; the directory structure should be as follows:

    X/javaapplication10/Main/Main.class
    X/javaapplication10/say/say.class

    Your classpath should point to X and your main class should be run as: application10.Main.Main

    kind regards,

    Jos
    That's only because the OP started flailing around misunderstanding what we were saying, and what they read.

    The original classes were fine...and that's what they should go back to, frankly.

  4. #24
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Tolls View Post
    That's only because the OP started flailing around misunderstanding what we were saying, and what they read.

    The original classes were fine...and that's what they should go back to, frankly.
    Yep, hence my replies #13 and #15; the OP has some incorrect idea in his/her mind how things should work, but they don't work that way and the OP still assumes he/she is correct. It is almost impossible to get through it ...

    kind regards,

    Jos

  5. #25
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by madsovenielsen View Post
    As i understand packages. after reading these tutorials:

    Java - Packages
    The Java Package Tutorial

    A package is just a folder that contains the files. in my situation: javaapplication10

    And yes the folder exists. :)
    If I'm correct, you've mentioned that you are working on NetBeans. So didn't you check the packages in the project list pane, and the physical folder path of it? ;) It maintain the folders as you mention, but the usage is differ at runtime.

  6. #26
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,792
    Rep Power
    25

    Default

    C:\Users\admin\Documents\NetBeansProjects\JavaAppl ication10\src\javaapplication10> java Main
    Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: javaapplication10/Main)
    The Main class is in a package whose name's case does not match the folder name.
    javaapplication10 vs JavaApplication10
    The Main.class file should be in the folder matching its package.
    The java command should use package name and class name and be issued in the folder that contains the package folder (NetBeansProjects):
    java javaapplication10.Main

  7. #27
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    The Main class is in a package whose name's case does not match the folder name.
    javaapplication10 vs JavaApplication10
    The Main.class file should be in the folder matching its package.
    The java command should use package name and class name and be issued in the folder that contains the package folder (NetBeansProjects):
    java javaapplication10.Main
    Almost right: the name of the class here is javaapplication10.Main (see the error message) but the op wants to start a class named Main (see the command line); s/he was already told how to do it several times and shown the appropriate tutorials but s/he wants to go on randomly (until success hits ;-)

    kind regards,

    Jos

  8. #28
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,792
    Rep Power
    25

    Default

    Whoops missed there were two folders with the same name (barring case differences) at different levels.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. "Cannot find symbol" errors in Java
    By 23Zone in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 08:13 AM
  2. Compiling probem "cannot find symbol"
    By thegluups in forum New To Java
    Replies: 27
    Last Post: 01-18-2010, 09:53 PM
  3. Error "can not find symbol variable"
    By FullMetalHollow in forum New To Java
    Replies: 5
    Last Post: 10-04-2009, 10:51 PM
  4. cannot find symbol for "list.addFirst"
    By alexbryan_08 in forum New To Java
    Replies: 10
    Last Post: 08-26-2009, 09:55 AM
  5. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 01:12 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
  •