Need help with SDK

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Allan Robertson

    Need help with SDK

    Hello

    I've downloaded the Java SDK 1.4.0 from Sun's website in the hope to
    learning Java, however when I compile my *.java files this (at most times)
    works fine, however when I run the *.class file using java.exe I get this
    error message.

    D:\jdk1.3\bin>j ava FirstLine.class

    Exception in thread "main" java.lang.NoCla ssDefFoundError : FirstLine/class

    I'm using Windows XP Pro with Java Runtime 1.4.0.
    Can anyone help me? Any help would be great.
    Thanks


  • Randall R Schulz

    #2
    Re: Need help with SDK

    Allan,

    Newbie mistake #23: The argument to the Java launcher (the "java"
    command) takes _class_ names, not class _file_ names as arguments.

    By including the ".class" suffix you instructd the Java launcher to
    invoke the "main" entry point in the class named "FirstLine.clas s"
    while I'm sure the class you wrote is called simply "FirstLine" .

    Also, get the latest J2SDK, which is now 1.4.2. Bugs are routinely
    fixed, performance improved and library API enhancements added.

    Similar complaints ("java.lang.NoC lassDefFoundErr or" can result from
    class-path and package naming problems. Be sure you understand these
    concepts and the java launcher options and environment variables that
    pertain to locating class files.

    Good luck.

    Randall Schulz


    Allan Robertson wrote:
    [color=blue]
    > Hello
    >
    > I've downloaded the Java SDK 1.4.0 from Sun's website in the hope
    > to learning Java, however when I compile my *.java files this (at
    > most times) works fine, however when I run the *.class file using
    > java.exe I get this error message.
    >
    > D:\jdk1.3\bin>j ava FirstLine.class
    >
    > Exception in thread "main" java.lang.NoCla ssDefFoundError :
    > FirstLine/class
    >
    > I'm using Windows XP Pro with Java Runtime 1.4.0. Can anyone help
    > me? Any help would be great.
    >
    > Thanks[/color]

    Comment

    • Randall R Schulz

      #3
      Re: Need help with SDK

      Phil,

      There is a convention in the Sun Java tools to map package nesting
      structures (with package names separated by dots, of course) to
      directories separated by slashes. That's what you're seeing in that
      exception diagnostic.

      Randall Schulz


      Phil... wrote:
      [color=blue]
      > A minor tweak on your otherwise excellent explanation. Note the
      > error message says FirstLine/class It thinks the dot means to go to
      > a subdirectory similar to what is done with import statements.[/color]

      Comment

      • Allan Robertson

        #4
        Re: Need help with SDK

        Thanks for your help, the code compiles fine now. I took your advice and
        downloaded the 1.4.2_01 SDK fron Sun. Thanks :)

        "Randall R Schulz" <rrschulz@cris. com> wrote in message
        news:RG6bb.2299 7$dk4.724063@ty phoon.sonic.net ...[color=blue]
        > Allan,
        >
        > Newbie mistake #23: The argument to the Java launcher (the "java"
        > command) takes _class_ names, not class _file_ names as arguments.
        >
        > By including the ".class" suffix you instructd the Java launcher to
        > invoke the "main" entry point in the class named "FirstLine.clas s"
        > while I'm sure the class you wrote is called simply "FirstLine" .
        >
        > Also, get the latest J2SDK, which is now 1.4.2. Bugs are routinely
        > fixed, performance improved and library API enhancements added.
        >
        > Similar complaints ("java.lang.NoC lassDefFoundErr or" can result from
        > class-path and package naming problems. Be sure you understand these
        > concepts and the java launcher options and environment variables that
        > pertain to locating class files.
        >
        > Good luck.
        >
        > Randall Schulz
        >
        >
        > Allan Robertson wrote:
        >[color=green]
        > > Hello
        > >
        > > I've downloaded the Java SDK 1.4.0 from Sun's website in the hope
        > > to learning Java, however when I compile my *.java files this (at
        > > most times) works fine, however when I run the *.class file using
        > > java.exe I get this error message.
        > >
        > > D:\jdk1.3\bin>j ava FirstLine.class
        > >
        > > Exception in thread "main" java.lang.NoCla ssDefFoundError :
        > > FirstLine/class
        > >
        > > I'm using Windows XP Pro with Java Runtime 1.4.0. Can anyone help
        > > me? Any help would be great.
        > >
        > > Thanks[/color]
        >[/color]


        Comment

        • Saurabh Manohar

          #5
          Re: Need help with SDK

          Have you added '.\' to the CLASSPATH variable
          add the line
          SET CLASSPATH=.';%C LASSPATH%
          in your c:\autoexec.bat
          HTH
          Saurabh
          "Allan Robertson" <nospam@nospam. com> wrote in message
          news:xj5bb.331$ tw3.71@news-binary.blueyond er.co.uk...[color=blue]
          > Hello
          >
          > I've downloaded the Java SDK 1.4.0 from Sun's website in the hope to
          > learning Java, however when I compile my *.java files this (at most times)
          > works fine, however when I run the *.class file using java.exe I get this
          > error message.
          >
          > D:\jdk1.3\bin>j ava FirstLine.class
          >
          > Exception in thread "main" java.lang.NoCla ssDefFoundError : FirstLine/class
          >
          > I'm using Windows XP Pro with Java Runtime 1.4.0.
          > Can anyone help me? Any help would be great.
          > Thanks
          >
          >[/color]


          Comment

          Working...