Java Classpath Problem

Discussion in 'Java' started by pitthekid, Jun 9, 2005.

  1. pitthekid

    pitthekid Guest

    Hello,

    I am programming java for quite a long time. In Windows I used always
    IDE (like Netbeans).

    This is the source
    package test;

    /**
    *
    * @author Weik
    */
    public class CallNativeMethods {

    /** Creates a new instance of CallNativeMethods */
    public CallNativeMethods() {
    }



    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here

    System.out.println("Hello from Java");
    }

    }


    I compiled it within the directory (It WinXP C:\test). If I now move
    one dirctory upward (C:) and type

    java test.CallNativeMethods

    I get
    Exception in thread "main" java.lang.NoClassDefFoundError:
    test/CallNativeMethods.


    If I put C:\test into the CLASSPATH Variable the same thing happens.

    What's the matter? I probably did a very stupid error??

    Thanks for help.

    Peter
    pitthekid, Jun 9, 2005
    #1
    1. Advertising

  2. "pitthekid" <> schreef in bericht
    news:...
    > Hello,
    >
    > I am programming java for quite a long time. In Windows I used always
    > IDE (like Netbeans).
    >
    > This is the source
    > package test;
    >
    > /**
    > *
    > * @author Weik
    > */
    > public class CallNativeMethods {
    >
    > /** Creates a new instance of CallNativeMethods */
    > public CallNativeMethods() {
    > }
    >
    >
    >
    > /**
    > * @param args the command line arguments
    > */
    > public static void main(String[] args) {
    > // TODO code application logic here
    >
    > System.out.println("Hello from Java");
    > }
    >
    > }
    >
    >
    > I compiled it within the directory (It WinXP C:\test). If I now move
    > one dirctory upward (C:) and type
    >
    > java test.CallNativeMethods
    >
    > I get
    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > test/CallNativeMethods.
    >
    >
    > If I put C:\test into the CLASSPATH Variable the same thing happens.


    If you do that, you should call
    java CallNativesMethods
    and you should make sure that the expected classpath is available from the
    console you are using.
    Boudewijn Dijkstra, Jun 9, 2005
    #2
    1. Advertising

  3. pitthekid

    John Currier Guest

    Where's the .class file? If it's c:\test\CallNativeMethods.class then
    your classpath (or -cp) needs to point to c:\.

    Note that you're going down a slippery slope by naming your classes
    with verbs. Classes should be nouns with verbs for methods.

    IMHO,
    John
    John Currier, Jun 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vnssoftware

    Ant Java Classpath

    vnssoftware, Oct 27, 2003, in forum: Java
    Replies:
    6
    Views:
    17,336
    christian Ginouvet
    Nov 9, 2003
  2. Flip
    Replies:
    3
    Views:
    7,259
    Tony Morris
    Feb 9, 2004
  3. Gabe
    Replies:
    3
    Views:
    1,071
  4. Replies:
    2
    Views:
    752
  5. Replies:
    2
    Views:
    1,105
    Mike Schilling
    Mar 2, 2008
Loading...

Share This Page