Still having problems with Java . . .

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

    #1

    Still having problems with Java . . .

    Hey. I've uninstalled netbeans, and installed just the SDK 1.4.2. I can
    compile .java files from the command prompt, but EVERY time I try to run
    ANY .class file, I get:

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

    What am I doing wring, here?
  • Raymond DeCampo

    #2
    Re: Still having problems with Java . . .

    Ash wrote:[color=blue]
    > Hey. I've uninstalled netbeans, and installed just the SDK 1.4.2. I can
    > compile .java files from the command prompt, but EVERY time I try to run
    > ANY .class file, I get:
    >
    > Exception in thread "main" java.lang.NoCla ssDefFoundError : Test/java
    >
    > What am I doing wring, here?[/color]

    Ash,

    To run a java class file, you pass the fully qualified name of the class
    to the java executable. The FQN is not the name of any file on your
    file system. It is the name of the package your class is in followed by
    the (short) name of your class.

    For example, when I was testing your TestFrame class you posted, I did
    the following:


    [tmp]$ cat >TestFrame.ja va
    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();
    }
    }
    [tmp]$ javac TestFrame.java
    Note: TestFrame.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    [tmp]$ java -cp . TestFrame

    HTH,
    Ray

    --
    XML is the programmer's duct tape.

    Comment

    • Hal Rosser

      #3
      Re: Still having problems with Java . . .

      > Hey. I've uninstalled netbeans, and installed just the SDK 1.4.2. I can[color=blue]
      > compile .java files from the command prompt, but EVERY time I try to run
      > ANY .class file, I get:
      >
      > Exception in thread "main" java.lang.NoCla ssDefFoundError : Test/java
      >
      > What am I doing wring, here?[/color]

      It sounds like you didn't name the file the same as the class name.
      OR - maybe you didn't import the needed classes for the app.
      post your code.



      ---
      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

      • glen herrmannsfeldt

        #4
        Re: Still having problems with Java . . .

        Hal Rosser wrote:[color=blue][color=green]
        >>Hey. I've uninstalled netbeans, and installed just the SDK 1.4.2. I can
        >>compile .java files from the command prompt, but EVERY time I try to run
        >>ANY .class file, I get:[/color][/color]
        [color=blue][color=green]
        >>Exception in thread "main" java.lang.NoCla ssDefFoundError : Test/java[/color][/color]
        [color=blue][color=green]
        >>What am I doing wring, here?[/color][/color]
        [color=blue]
        > It sounds like you didn't name the file the same as the class name.
        > OR - maybe you didn't import the needed classes for the app.
        > post your code.[/color]

        It can be more confusing on Windows with a case insensitive
        file system. You have to match the case of the class
        name even if it isn't the case of the file name. The system
        will find the file, but not the class.

        -- glen

        Comment

        Working...