Results 1 to 9 of 9
  1. #1
    svaidya is offline Member
    Join Date
    Dec 2009
    Posts
    9
    Rep Power
    0

    Default compiling a package user created

    Hi
    I am tryingt o compile a bunch of .java files and a package created linkList.But keep getting the runtime error:
    Exception in thread "main" java.lang.NoClassDefFoundError: LinkListTest (wrong n
    ame: linkList/LinkListTest)

    The LinkListTest has the main in it.this class is part of the linkList package.

    Thanks
    shweta

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    I am tryingt o compile a bunch of .java files and a package created linkList.But keep getting the runtime error:

    So are you trying to compile or run?

    If you are trying to run the program then there is something wrong with the command you are using. It would be a good idea to say just what that command is and how it relates to the location of the various .class files involved.

    A typical invocation of java.exe would look like:

    Java Code:
    c:\whereever > java -cp . linkList.LinkListTest

    where "wherever" is the directory containing the linkList directory.

  3. #3
    svaidya is offline Member
    Join Date
    Dec 2009
    Posts
    9
    Rep Power
    0

    Default

    Hi
    I am trying to run the program.The package compiles.

    tried java -cp.linkList.LinkListTest

    Got:
    Unrecognized option: -cp.linkList.LinkListTest
    Could not create the Java virtual machine.

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

    Default

    Quote Originally Posted by svaidya View Post
    Hi
    I am trying to run the program.The package compiles.

    tried java -cp.linkList.LinkListTest

    Got:
    Unrecognized option: -cp.linkList.LinkListTest
    Could not create the Java virtual machine.
    Put spaces in between, as in: java<space>-cp<space><dot><space><your class name>, just as Pbrockway2 did ...

    kind regards,

    Jos

  5. #5
    svaidya is offline Member
    Join Date
    Dec 2009
    Posts
    9
    Rep Power
    0

    Default

    Hi
    Still doesnot work
    C:\Users\Manish\Desktop\elance\example>java -cp . linkList.LinkListTest
    Exception in thread "main" java.lang.NoClassDefFoundError: linkList/LinkLi

    Caused by: java.lang.ClassNotFoundException: linkList.LinkListTest
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: linkList.LinkListTest. Program will exit.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by svaidya View Post
    Hi
    Still doesnot work
    C:\Users\Manish\Desktop\elance\example>java -cp . linkList.LinkListTest
    Is the absolute path of your file: C:\Users\Manish\Desktop\elance\example\linkList\Li nkListTest.class ?
    And does the source of that class contain a line "package linkList;"?

    kind regards,

    Jos

  7. #7
    svaidya is offline Member
    Join Date
    Dec 2009
    Posts
    9
    Rep Power
    0

    Default

    the path is C:\Users\Manish\Desktop\elance\example -> the example folder has LinkListTest.java there is no folder linkList.yes the files have the line package linkList.Should I make a folder linkList and put the files in them?

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by svaidya View Post
    the path is C:\Users\Manish\Desktop\elance\example -> the example folder has LinkListTest.java there is no folder linkList.yes the files have the line package linkList.Should I make a folder linkList and put the files in them?
    Yes, as Pbrockway2 already suggested ...

    kind regards,

    Jos

    ps. the javac compiler has a flag; if set it does that for you.

  9. #9
    svaidya is offline Member
    Join Date
    Dec 2009
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Package Compiling
    By kaperks in forum Advanced Java
    Replies: 1
    Last Post: 02-23-2009, 02:56 PM
  2. Replies: 1
    Last Post: 02-20-2009, 03:49 PM
  3. [SOLVED] Compiling Package Class
    By nwboy74 in forum New To Java
    Replies: 3
    Last Post: 11-14-2008, 11:19 PM
  4. Compiling a class in a package from cmd
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 10:27 AM
  5. Importing / compiling and running with .jar package
    By splinter64uk in forum New To Java
    Replies: 1
    Last Post: 12-05-2007, 02:47 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
  •