• Post Reply Bookmark Topic Watch Topic
  • New Topic

error in executing the java progragm  RSS feed

 
s.raghu pathy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hava installed java jdk1.3 in my system.When i compile a java file it gets compiled.But if i run the program using the command "java class-name" i get error reading "Exception in thread "main" java.lang.NoClassDefFoundError:class-name".i have saved the java file only by its class name.please help me....
 
Sanjaya Sugiarto
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
typical classpath problem. Add CLASSPATH in your system variables.
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Check these following:

1) Make sure that classpath is correct and using ; to seperate the class paths.

2) Make sure that you are in correct directory to access.

3) Specify the full packagename along with class.

For Example:

for SOurce:
---------------

package com.dtcc;
public class hello{
}
---------------

Then you have to invoke the class file as

java com.dtcc.hello;

if still problem persists do following,

1) Compile with javac -d . *.java
2) set CLASSPATH=.;%CLASSPATH%
3) java <packageName>.<className>

It will work
all the best
 
Jay Suttiruttana
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you have the main() function declared properly. This seems to be a common mistake.

public static void main(String[] argv){}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!