Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java Classpath Problem

Reply
Thread Tools

Java Classpath Problem

 
 
pitthekid
Guest
Posts: n/a
 
      06-09-2005
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

 
Reply With Quote
 
 
 
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      06-09-2005
"pitthekid" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.com...
> 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.


 
Reply With Quote
 
 
 
 
John Currier
Guest
Posts: n/a
 
      06-10-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.classpath file instead of the CLASSPATH Environment variable. dontspammenow@yahoo.com Java 2 03-02-2008 08:19 AM
problem compiling project, classpath in xml ".classpath" "<classpathentry...>" jameshanley39@yahoo.co.uk Java 2 03-02-2007 12:37 PM
while using javac -classpath some.jar some.java (Where does classpath get stored?) Gabe Java 3 08-27-2004 07:02 PM
CLASSPATH, -cp and -classpath misunderstanding? Flip Java 3 02-09-2004 10:09 PM
Ant Java Classpath vnssoftware Java 6 11-09-2003 08:31 PM



Advertisments