Java Classpath Problem

P

pitthekid

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
 
B

Boudewijn Dijkstra

pitthekid said:
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.
 
J

John Currier

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top