Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

classpath

 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am in my root directory /work/vsubra. I have file A.java in this directory. When I compile useing javac A.java it does create a class in the same dir as A.class. But when I run it using java A then it gives me this error
Exception in thread "main" java.lang.NoClassDefFound error
i have given the path in my classpath also for rt.jar. The path goes as
/usr/java131/jre/lib/rt.jar;.
Why this error then?
 
mohsin shahzad
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Report post to moderator
thrweth
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Report post to moderator
the command line should be
java -classpath . A
Moving this to the Java in General (Beginner) forum.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
You said it Mohsin!
It's also possible that the class A is declared to be in a package other than the default. Is there a line in A.java similar to:
package something;
?
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post. Thanks.
[ January 22, 2003: Message edited by: Marilyn de Queiroz ]
 
    Bookmark Topic Watch Topic
  • New Topic