Exception in thread "main" java.lang.NoClassDefFoundError:

I go this Class located in /root/com/one

package com.one;

publicclass Add

{

publicint add(int x,int y)

{

int result =x+y;

return result;

}

}

When i am trying to compile Test class ; Located /root/Desktop

import com.one.Add;

publicclass Test

{

publicstaticvoid main(String args[])

{

Add obj =new Add();

System.out.println(obj.add(4,6));

}

}

With this command (i am currently in /root/Desktop)

javac -classpath .:/root Test.java

it compile, but when i try to run it : java Test

i got this error

Exception in thread "main" java.lang.NoClassDefFoundError: com/one/Add

at Test.main(Test.java:13)

Any idea what i am doing wrong

Message was edited by:

AQ_Java

[1580 byte] By [AQ_Javaa] at [2007-11-27 10:48:04]
# 1

set the classpath while runnig also,

it should solve the issue.

gaurav_abbia at 2007-7-28 22:24:12 > top of Java-index,Java Essentials,Java Programming...
# 2

You mean like that

set CLASSPATH=%CLASSPATH%:/com/one

it didn't work

AQ_Javaa at 2007-7-28 22:24:12 > top of Java-index,Java Essentials,Java Programming...
# 3

ok worked as you said thanks

java -classpath .:/root Ahmad

AQ_Javaa at 2007-7-28 22:24:12 > top of Java-index,Java Essentials,Java Programming...