Problem starting out with Java . . .

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

    Problem starting out with Java . . .

    Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
    every time i try to import java.awt.* , I can't use any of the
    methods(like they don't exist). I can compile it fine, but when I try to
    run it, I get "exception in class main".

    Can anyone help me, please?
  • flaps81

    #2
    Re: Problem starting out with Java . . .

    On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
    wrote:
    [color=blue]
    >Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
    >every time i try to import java.awt.* , I can't use any of the
    >methods(like they don't exist). I can compile it fine, but when I try to
    >run it, I get "exception in class main".
    >
    >Can anyone help me, please?[/color]

    Post the code that gives you trouble, an exception can be many
    things...

    Comment

    • Ash

      #3
      Re: Problem starting out with Java . . .

      flaps81 wrote:[color=blue]
      > On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
      > wrote:
      >
      >[color=green]
      >>Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
      >>every time i try to import java.awt.* , I can't use any of the
      >>methods(lik e they don't exist). I can compile it fine, but when I try to
      >>run it, I get "exception in class main".
      >>
      >>Can anyone help me, please?[/color]
      >
      >
      > Post the code that gives you trouble, an exception can be many
      > things...[/color]
      OK - Here it is:

      import java.awt.*;
      public class TestFrame
      {
      public static void main(String[] args)
      {
      Frame f = new Frame();
      f.reshape(10,10 ,200,200);

      Button b = new Button("Hello Cyberspace");
      b.setBackground (Color.black);
      b.setForeground (Color.white);
      f.add(b);
      f.show();
      }
      }

      Like I said - it compiles fine, but gives me an exception every time I
      try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.

      Thanks

      Comment

      • Raymond DeCampo

        #4
        Re: Problem starting out with Java . . .

        Ash wrote:[color=blue]
        > flaps81 wrote:
        >[color=green]
        >> On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
        >> wrote:
        >>
        >>[color=darkred]
        >>> Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
        >>> every time i try to import java.awt.* , I can't use any of the
        >>> methods(like they don't exist). I can compile it fine, but when I try
        >>> to run it, I get "exception in class main".
        >>>
        >>> Can anyone help me, please?[/color]
        >>
        >>
        >>
        >> Post the code that gives you trouble, an exception can be many
        >> things...[/color]
        >
        > OK - Here it is:
        >
        > import java.awt.*;
        > public class TestFrame
        > {
        > public static void main(String[] args)
        > {
        > Frame f = new Frame();
        > f.reshape(10,10 ,200,200);
        >
        > Button b = new Button("Hello Cyberspace");
        > b.setBackground (Color.black);
        > b.setForeground (Color.white);
        > f.add(b);
        > f.show();
        > }
        > }
        >
        > Like I said - it compiles fine, but gives me an exception every time I
        > try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
        >[/color]

        This program compiles fine (although with a deprecation warning on
        reshape()) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
        muddy the waters). Please post the exception you are getting. Also, I
        would encourage you to try this on the command line if you haven't
        already to determine if NetBeans is the problem.

        HTH,
        Ray

        --
        XML is the programmer's duct tape.

        Comment

        • Ash

          #5
          Re: Problem starting out with Java . . .

          Raymond DeCampo wrote:[color=blue]
          > Ash wrote:
          >[color=green]
          >> flaps81 wrote:
          >>[color=darkred]
          >>> On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
          >>> wrote:
          >>>
          >>>
          >>>> Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
          >>>> every time i try to import java.awt.* , I can't use any of the
          >>>> methods(like they don't exist). I can compile it fine, but when I
          >>>> try to run it, I get "exception in class main".
          >>>>
          >>>> Can anyone help me, please?
          >>>
          >>>
          >>>
          >>>
          >>> Post the code that gives you trouble, an exception can be many
          >>> things...[/color]
          >>
          >>
          >> OK - Here it is:
          >>
          >> import java.awt.*;
          >> public class TestFrame
          >> {
          >> public static void main(String[] args)
          >> {
          >> Frame f = new Frame();
          >> f.reshape(10,10 ,200,200);
          >>
          >> Button b = new Button("Hello Cyberspace");
          >> b.setBackground (Color.black);
          >> b.setForeground (Color.white);
          >> f.add(b);
          >> f.show();
          >> }
          >> }
          >>
          >> Like I said - it compiles fine, but gives me an exception every time I
          >> try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
          >>[/color]
          >
          > This program compiles fine (although with a deprecation warning on
          > reshape()) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
          > muddy the waters). Please post the exception you are getting. Also, I
          > would encourage you to try this on the command line if you haven't
          > already to determine if NetBeans is the problem.
          >
          > HTH,
          > Ray
          >[/color]
          Nice sig. Ok - I get this from the compiler output:

          Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a deprecated
          API.
          Note: Recompile with -deprecation for details.
          Finished TestFrame.

          and this from the program output:

          java.lang.NoCla ssDefFoundError : Bin/eXtropia/TestFrame (wrong name:
          TestFrame)
          at java.lang.Class Loader.defineCl ass0(Native Method)
          at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
          at
          java.security.S ecureClassLoade r.defineClass(S ecureClassLoade r.java:123)
          at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
          at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
          at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
          at java.security.A ccessController .doPrivileged(N ative Method)
          at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
          at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
          at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
          at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
          at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
          Exception in thread "main"

          I'll try doing it throught the command window.

          Comment

          • Ash

            #6
            Re: Problem starting out with Java . . .

            Ash wrote:[color=blue]
            > Raymond DeCampo wrote:
            >[color=green]
            >> Ash wrote:
            >>[color=darkred]
            >>> flaps81 wrote:
            >>>
            >>>> On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
            >>>> wrote:
            >>>>
            >>>>
            >>>>> Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
            >>>>> every time i try to import java.awt.* , I can't use any of the
            >>>>> methods(like they don't exist). I can compile it fine, but when I
            >>>>> try to run it, I get "exception in class main".
            >>>>>
            >>>>> Can anyone help me, please?
            >>>>
            >>>>
            >>>>
            >>>>
            >>>>
            >>>> Post the code that gives you trouble, an exception can be many
            >>>> things...
            >>>
            >>>
            >>>
            >>> OK - Here it is:
            >>>
            >>> import java.awt.*;
            >>> public class TestFrame
            >>> {
            >>> public static void main(String[] args)
            >>> {
            >>> Frame f = new Frame();
            >>> f.reshape(10,10 ,200,200);
            >>>
            >>> Button b = new Button("Hello Cyberspace");
            >>> b.setBackground (Color.black);
            >>> b.setForeground (Color.white);
            >>> f.add(b);
            >>> f.show();
            >>> }
            >>> }
            >>>
            >>> Like I said - it compiles fine, but gives me an exception every time
            >>> I try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
            >>>[/color]
            >>
            >> This program compiles fine (although with a deprecation warning on
            >> reshape()) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
            >> muddy the waters). Please post the exception you are getting. Also,
            >> I would encourage you to try this on the command line if you haven't
            >> already to determine if NetBeans is the problem.
            >>
            >> HTH,
            >> Ray
            >>[/color]
            > Nice sig. Ok - I get this from the compiler output:
            >
            > Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a deprecated
            > API.
            > Note: Recompile with -deprecation for details.
            > Finished TestFrame.
            >
            > and this from the program output:
            >
            > java.lang.NoCla ssDefFoundError : Bin/eXtropia/TestFrame (wrong name:
            > TestFrame)
            > at java.lang.Class Loader.defineCl ass0(Native Method)
            > at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
            > at
            > java.security.S ecureClassLoade r.defineClass(S ecureClassLoade r.java:123)
            > at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
            > at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
            > at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
            > at java.security.A ccessController .doPrivileged(N ative Method)
            > at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
            > at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
            > at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
            > at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
            > at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
            > Exception in thread "main"
            >
            > I'll try doing it throught the command window.[/color]
            Under the cmd window, I get
            D:\Java\Bin\eXt ropia>java TestFrame.class
            Exception in thread "main" java.lang.NoCla ssDefFoundError : TestFrame/class

            Comment

            • flaps81

              #7
              Re: Problem starting out with Java . . .

              On Sun, 24 Oct 2004 16:09:31 GMT, Ash <furroash@nb.sy mpatico.ca>
              wrote:
              [color=blue]
              >Ash wrote:[color=green]
              >> Raymond DeCampo wrote:
              >>[color=darkred]
              >>> Ash wrote:
              >>>
              >>>> flaps81 wrote:
              >>>>
              >>>>> On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
              >>>>> wrote:
              >>>>>
              >>>>>
              >>>>>> Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
              >>>>>> every time i try to import java.awt.* , I can't use any of the
              >>>>>> methods(like they don't exist). I can compile it fine, but when I
              >>>>>> try to run it, I get "exception in class main".
              >>>>>>
              >>>>>> Can anyone help me, please?
              >>>>>
              >>>>>
              >>>>>
              >>>>>
              >>>>>
              >>>>> Post the code that gives you trouble, an exception can be many
              >>>>> things...
              >>>>
              >>>>
              >>>>
              >>>> OK - Here it is:
              >>>>
              >>>> import java.awt.*;
              >>>> public class TestFrame
              >>>> {
              >>>> public static void main(String[] args)
              >>>> {
              >>>> Frame f = new Frame();
              >>>> f.reshape(10,10 ,200,200);
              >>>>
              >>>> Button b = new Button("Hello Cyberspace");
              >>>> b.setBackground (Color.black);
              >>>> b.setForeground (Color.white);
              >>>> f.add(b);
              >>>> f.show();
              >>>> }
              >>>> }
              >>>>
              >>>> Like I said - it compiles fine, but gives me an exception every time
              >>>> I try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
              >>>>
              >>>
              >>> This program compiles fine (although with a deprecation warning on
              >>> reshape()) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
              >>> muddy the waters). Please post the exception you are getting. Also,
              >>> I would encourage you to try this on the command line if you haven't
              >>> already to determine if NetBeans is the problem.
              >>>
              >>> HTH,
              >>> Ray
              >>>[/color]
              >> Nice sig. Ok - I get this from the compiler output:
              >>
              >> Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a deprecated
              >> API.
              >> Note: Recompile with -deprecation for details.
              >> Finished TestFrame.
              >>
              >> and this from the program output:
              >>
              >> java.lang.NoCla ssDefFoundError : Bin/eXtropia/TestFrame (wrong name:
              >> TestFrame)
              >> at java.lang.Class Loader.defineCl ass0(Native Method)
              >> at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
              >> at
              >> java.security.S ecureClassLoade r.defineClass(S ecureClassLoade r.java:123)
              >> at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
              >> at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
              >> at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
              >> at java.security.A ccessController .doPrivileged(N ative Method)
              >> at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
              >> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
              >> at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
              >> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
              >> at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
              >> Exception in thread "main"
              >>
              >> I'll try doing it throught the command window.[/color]
              >Under the cmd window, I get
              >D:\Java\Bin\eX tropia>java TestFrame.class
              >Exception in thread "main" java.lang.NoCla ssDefFoundError : TestFrame/class[/color]


              Are you sure that the file is named TestFrame.java !?!

              Comment

              • Ash

                #8
                Re: Problem starting out with Java . . .

                flaps81 wrote:[color=blue]
                > On Sun, 24 Oct 2004 16:09:31 GMT, Ash <furroash@nb.sy mpatico.ca>
                > wrote:
                >
                >[color=green]
                >>Ash wrote:
                >>[color=darkred]
                >>>Raymond DeCampo wrote:
                >>>
                >>>
                >>>>Ash wrote:
                >>>>
                >>>>
                >>>>>flaps81 wrote:
                >>>>>
                >>>>>
                >>>>>>On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
                >>>>>>wrote:
                >>>>>>
                >>>>>>
                >>>>>>
                >>>>>>>Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                >>>>>>>every time i try to import java.awt.* , I can't use any of the
                >>>>>>>methods( like they don't exist). I can compile it fine, but when I
                >>>>>>>try to run it, I get "exception in class main".
                >>>>>>>
                >>>>>>>Can anyone help me, please?
                >>>>>>
                >>>>>>
                >>>>>>
                >>>>>>
                >>>>>>
                >>>>>>Post the code that gives you trouble, an exception can be many
                >>>>>>things. ..
                >>>>>
                >>>>>
                >>>>>
                >>>>>OK - Here it is:
                >>>>>
                >>>>>import java.awt.*;
                >>>>>public class TestFrame
                >>>>> {
                >>>>> public static void main(String[] args)
                >>>>> {
                >>>>> Frame f = new Frame();
                >>>>> f.reshape(10,10 ,200,200);
                >>>>>
                >>>>> Button b = new Button("Hello Cyberspace");
                >>>>> b.setBackground (Color.black);
                >>>>> b.setForeground (Color.white);
                >>>>> f.add(b);
                >>>>> f.show();
                >>>>> }
                >>>>> }
                >>>>>
                >>>>>Like I said - it compiles fine, but gives me an exception every time
                >>>>>I try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
                >>>>>
                >>>>
                >>>>This program compiles fine (although with a deprecation warning on
                >>>>reshape() ) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
                >>>>muddy the waters). Please post the exception you are getting. Also,
                >>>>I would encourage you to try this on the command line if you haven't
                >>>>already to determine if NetBeans is the problem.
                >>>>
                >>>>HTH,
                >>>>Ray
                >>>>
                >>>
                >>>Nice sig. Ok - I get this from the compiler output:
                >>>
                >>>Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a deprecated
                >>>API.
                >>>Note: Recompile with -deprecation for details.
                >>>Finished TestFrame.
                >>>
                >>>and this from the program output:
                >>>
                >>>java.lang.No ClassDefFoundEr ror: Bin/eXtropia/TestFrame (wrong name:
                >>>TestFrame)
                >>> at java.lang.Class Loader.defineCl ass0(Native Method)
                >>> at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
                >>> at
                >>>java.securit y.SecureClassLo ader.defineClas s(SecureClassLo ader.java:123)
                >>> at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
                >>> at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
                >>> at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
                >>> at java.security.A ccessController .doPrivileged(N ative Method)
                >>> at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
                >>> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
                >>> at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
                >>> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
                >>> at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
                >>>Exception in thread "main"
                >>>
                >>>I'll try doing it throught the command window.[/color]
                >>
                >>Under the cmd window, I get
                >>D:\Java\Bin\e Xtropia>java TestFrame.class
                >>Exception in thread "main" java.lang.NoCla ssDefFoundError : TestFrame/class[/color]
                >
                >
                >
                > Are you sure that the file is named TestFrame.java !?![/color]
                YES! And I have NO IDEA what I'm doing wrong! I've added the Bin folder
                to my path and classpath variables! I've copied the SIMPLEST SOURCES off
                the web and ALWAYS it does this! What am I doing wrong!?!

                :(

                Comment

                • flaps81

                  #9
                  Re: Problem starting out with Java . . .

                  On Sun, 24 Oct 2004 17:18:47 GMT, Ash <furroash@nb.sy mpatico.ca>
                  wrote:
                  [color=blue]
                  >flaps81 wrote:[color=green]
                  >> On Sun, 24 Oct 2004 16:09:31 GMT, Ash <furroash@nb.sy mpatico.ca>
                  >> wrote:
                  >>
                  >>[color=darkred]
                  >>>Ash wrote:
                  >>>
                  >>>>Raymond DeCampo wrote:
                  >>>>
                  >>>>
                  >>>>>Ash wrote:
                  >>>>>
                  >>>>>
                  >>>>>>flaps81 wrote:
                  >>>>>>
                  >>>>>>
                  >>>>>>>On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
                  >>>>>>>wrote:
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>>Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                  >>>>>>>>every time i try to import java.awt.* , I can't use any of the
                  >>>>>>>>methods (like they don't exist). I can compile it fine, but when I
                  >>>>>>>>try to run it, I get "exception in class main".
                  >>>>>>>>
                  >>>>>>>>Can anyone help me, please?
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>Post the code that gives you trouble, an exception can be many
                  >>>>>>>things.. .
                  >>>>>>
                  >>>>>>
                  >>>>>>
                  >>>>>>OK - Here it is:
                  >>>>>>
                  >>>>>>import java.awt.*;
                  >>>>>>public class TestFrame
                  >>>>>> {
                  >>>>>> public static void main(String[] args)
                  >>>>>> {
                  >>>>>> Frame f = new Frame();
                  >>>>>> f.reshape(10,10 ,200,200);
                  >>>>>>
                  >>>>>> Button b = new Button("Hello Cyberspace");
                  >>>>>> b.setBackground (Color.black);
                  >>>>>> b.setForeground (Color.white);
                  >>>>>> f.add(b);
                  >>>>>> f.show();
                  >>>>>> }
                  >>>>>> }
                  >>>>>>
                  >>>>>>Like I said - it compiles fine, but gives me an exception every time
                  >>>>>>I try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
                  >>>>>>
                  >>>>>
                  >>>>>This program compiles fine (although with a deprecation warning on
                  >>>>>reshape( )) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
                  >>>>>muddy the waters). Please post the exception you are getting. Also,
                  >>>>>I would encourage you to try this on the command line if you haven't
                  >>>>>already to determine if NetBeans is the problem.
                  >>>>>
                  >>>>>HTH,
                  >>>>>Ray
                  >>>>>
                  >>>>
                  >>>>Nice sig. Ok - I get this from the compiler output:
                  >>>>
                  >>>>Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a deprecated
                  >>>>API.
                  >>>>Note: Recompile with -deprecation for details.
                  >>>>Finished TestFrame.
                  >>>>
                  >>>>and this from the program output:
                  >>>>
                  >>>>java.lang.N oClassDefFoundE rror: Bin/eXtropia/TestFrame (wrong name:
                  >>>>TestFrame )
                  >>>> at java.lang.Class Loader.defineCl ass0(Native Method)
                  >>>> at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
                  >>>> at
                  >>>>java.securi ty.SecureClassL oader.defineCla ss(SecureClassL oader.java:123)
                  >>>> at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
                  >>>> at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
                  >>>> at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
                  >>>> at java.security.A ccessController .doPrivileged(N ative Method)
                  >>>> at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
                  >>>> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
                  >>>> at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
                  >>>> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
                  >>>> at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
                  >>>>Exception in thread "main"
                  >>>>
                  >>>>I'll try doing it throught the command window.
                  >>>
                  >>>Under the cmd window, I get
                  >>>D:\Java\Bin\ eXtropia>java TestFrame.class
                  >>>Exception in thread "main" java.lang.NoCla ssDefFoundError : TestFrame/class[/color]
                  >>
                  >>
                  >>
                  >> Are you sure that the file is named TestFrame.java !?![/color]
                  >YES! And I have NO IDEA what I'm doing wrong! I've added the Bin folder
                  >to my path and classpath variables! I've copied the SIMPLEST SOURCES off
                  >the web and ALWAYS it does this! What am I doing wrong!?!
                  >
                  >:([/color]

                  Beats me, I've tried to copy paste the code you posted and it works
                  fine. The only way I can get a java.lang.NoCla ssDefFoundError is if
                  the filename is wrong...

                  Comment

                  • Michael Saunby

                    #10
                    Re: Problem starting out with Java . . .


                    "Ash" <furroash@nb.sy mpatico.ca> wrote in message
                    news:XtRed.1537 61$Np3.6644333@ ursa-nb00s0.nbnet.nb .ca...[color=blue][color=green][color=darkred]
                    >>>
                    >>>Under the cmd window, I get
                    >>>D:\Java\Bin\ eXtropia>java TestFrame.class
                    >>>Exception in thread "main" java.lang.NoCla ssDefFoundError :
                    >>>TestFrame/class[/color]
                    >>
                    >>
                    >>
                    >> Are you sure that the file is named TestFrame.java !?![/color]
                    > YES! And I have NO IDEA what I'm doing wrong! I've added the Bin folder
                    > to my path and classpath variables! I've copied the SIMPLEST SOURCES off
                    > the web and ALWAYS it does this! What am I doing wrong!?!
                    >[/color]

                    You're not typing "java TestFrame" but that alone might not fix things. I
                    can't be bothered to sort through all your output.

                    Basically it's like this - "java someclass" will execute main() in
                    "someclass" (it must be static) which will have the filename
                    "someclass.clas s" and the soucefile will be called "someclass.java ". Of
                    course the class could be in a package, which would require you to run it
                    using "java packagename.som eclass".

                    The fact that you have NO IDEA suggests that you really ought to read
                    rather more and post less. There's loads of info at http://java.sun.com
                    Unless you really enjoy looking stupid.

                    Michael Saunby



                    Comment

                    • Ash

                      #11
                      Re: Problem starting out with Java . . .

                      Ash wrote:[color=blue]
                      > Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                      > every time i try to import java.awt.* , I can't use any of the
                      > methods(like they don't exist). I can compile it fine, but when I try to
                      > run it, I get "exception in class main".
                      >
                      > Can anyone help me, please?[/color]
                      OK - when I reinstalled netbeans, their sample helloworld app worked
                      fine - untill I removed this line:

                      package bin;

                      What is that for?

                      Comment

                      • The Abrasive Sponge

                        #12
                        Re: Problem starting out with Java . . .

                        Ash wrote:
                        [color=blue]
                        > Ash wrote:
                        >[color=green]
                        >> Raymond DeCampo wrote:
                        >>[color=darkred]
                        >>> Ash wrote:
                        >>>
                        >>>> flaps81 wrote:
                        >>>>
                        >>>>> On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
                        >>>>> wrote:
                        >>>>>
                        >>>>>
                        >>>>>> Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                        >>>>>> every time i try to import java.awt.* , I can't use any of the
                        >>>>>> methods(like they don't exist). I can compile it fine, but when I
                        >>>>>> try to run it, I get "exception in class main".
                        >>>>>>
                        >>>>>> Can anyone help me, please?
                        >>>>>
                        >>>>>
                        >>>>>
                        >>>>>
                        >>>>>
                        >>>>>
                        >>>>> Post the code that gives you trouble, an exception can be many
                        >>>>> things...
                        >>>>
                        >>>>
                        >>>>
                        >>>>
                        >>>> OK - Here it is:
                        >>>>
                        >>>> import java.awt.*;
                        >>>> public class TestFrame
                        >>>> {
                        >>>> public static void main(String[] args)
                        >>>> {
                        >>>> Frame f = new Frame();
                        >>>> f.reshape(10,10 ,200,200);
                        >>>>
                        >>>> Button b = new Button("Hello Cyberspace");
                        >>>> b.setBackground (Color.black);
                        >>>> b.setForeground (Color.white);
                        >>>> f.add(b);
                        >>>> f.show();
                        >>>> }
                        >>>> }
                        >>>>
                        >>>> Like I said - it compiles fine, but gives me an exception every time
                        >>>> I try to run it. I'm using NetBeans 3.6 and J2SKD 1.4.2.
                        >>>>
                        >>>
                        >>> This program compiles fine (although with a deprecation warning on
                        >>> reshape()) and runs fine for me (JDK 1.4.2_04-b05 on linux, no IDE to
                        >>> muddy the waters). Please post the exception you are getting. Also,
                        >>> I would encourage you to try this on the command line if you haven't
                        >>> already to determine if NetBeans is the problem.
                        >>>
                        >>> HTH,
                        >>> Ray
                        >>>[/color]
                        >> Nice sig. Ok - I get this from the compiler output:
                        >>
                        >> Note: D:\Java\Bin\eXt ropia\TestFrame .java uses or overrides a
                        >> deprecated API.
                        >> Note: Recompile with -deprecation for details.
                        >> Finished TestFrame.
                        >>
                        >> and this from the program output:
                        >>
                        >> java.lang.NoCla ssDefFoundError : Bin/eXtropia/TestFrame (wrong name:
                        >> TestFrame)
                        >> at java.lang.Class Loader.defineCl ass0(Native Method)
                        >> at java.lang.Class Loader.defineCl ass(ClassLoader .java:537)
                        >> at
                        >> java.security.S ecureClassLoade r.defineClass(S ecureClassLoade r.java:123)
                        >> at java.net.URLCla ssLoader.define Class(URLClassL oader.java:251)
                        >> at java.net.URLCla ssLoader.access $100(URLClassLo ader.java:55)
                        >> at java.net.URLCla ssLoader$1.run( URLClassLoader. java:194)
                        >> at java.security.A ccessController .doPrivileged(N ative Method)
                        >> at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:187)
                        >> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:289)
                        >> at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:274 )
                        >> at java.lang.Class Loader.loadClas s(ClassLoader.j ava:235)
                        >> at java.lang.Class Loader.loadClas sInternal(Class Loader.java:302 )
                        >> Exception in thread "main"
                        >>
                        >> I'll try doing it throught the command window.[/color]
                        >
                        > Under the cmd window, I get
                        > D:\Java\Bin\eXt ropia>java TestFrame.class
                        > Exception in thread "main" java.lang.NoCla ssDefFoundError : TestFrame/class[/color]


                        Run it as:
                        D:\Java\Bin\eXt ropia>java TestFrame

                        Leave out the .class when creating a new VM. :)

                        Comment

                        • Hal Rosser

                          #13
                          Re: Problem starting out with Java . . .


                          "Ash" <furroash@nb.sy mpatico.ca> wrote in message
                          news:_dDed.1534 96$Np3.6625750@ ursa-nb00s0.nbnet.nb .ca...[color=blue]
                          > Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                          > every time i try to import java.awt.* , I can't use any of the
                          > methods(like they don't exist). I can compile it fine, but when I try to
                          > run it, I get "exception in class main".
                          >
                          > Can anyone help me, please?[/color]

                          Start out with notepad - not netbeans.



                          ---
                          Outgoing mail is certified Virus Free.
                          Checked by AVG anti-virus system (http://www.grisoft.com).
                          Version: 6.0.781 / Virus Database: 527 - Release Date: 10/21/2004


                          Comment

                          • Ash

                            #14
                            Re: Problem starting out with Java . . .

                            flaps81 wrote:[color=blue]
                            > On Sun, 24 Oct 2004 01:06:02 GMT, Ash <furroash@nb.sy mpatico.ca>
                            > wrote:
                            >
                            >[color=green]
                            >>Hey. Im new to Java, and am having a prroblem with the netbeans IDE.
                            >>every time i try to import java.awt.* , I can't use any of the
                            >>methods(lik e they don't exist). I can compile it fine, but when I try to
                            >>run it, I get "exception in class main".
                            >>
                            >>Can anyone help me, please?[/color]
                            >
                            >
                            > Post the code that gives you trouble, an exception can be many
                            > things...[/color]
                            ARG!!!!!!!!!!!!

                            I HAVE *NO* JAVA.LANG FILES! ANYWHERE! WTF!?! I TRY TO USE jikes.exe
                            INSTEAD, and it gives me

                            *** Semantic Error: You need to modify your classpath, sourcepath,
                            bootclasspath
                            , and/or extdirs setup. Jikes could not find package "java.lang" in:

                            WTF!?! Please help!

                            Comment

                            Working...