This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Path Problem

 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

I have a problem in executing the following program

package com;
public class man {

public static void main(String[] args) {
System.out.println("1");
}
}

1. The above program has been saved in c:\projects\source\com\man.java
2. I compiled the above by issuing following command
c:\projects\> javac -d classes source\com\man.java
The output was a successful compilation & the class file was available in c:\projects\classes\com\man.class
3. now when I try to executive the above class
c:\projects\classes\com> java man
I get the following Exception in thread "main" java.lang.NoClassDefFoundError: man

I know that it has got something to do with setting the classpath, but I am not able to figure it out how....please help,

shashank
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try...

c:\projects\classes>java com.man
 
Ravinder Singh
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this; it should work:
c:\projects\classes>java -classpath . com.man

----------
Ravinder
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mark, it worked...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic