• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange Error...

 
Jayanath
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im using j2sdk1.4.0
when Im compiling this small class it get compiled.
when I try to execute it it gave me an error saying,

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

Whats wrong with this???
Pls help me to clarify this strange error...

Thanx in advance for any comments,
best regs,
Jayanath.

import java.io.*;
public class test
{
public static void main(String arr[])
{
System.out.println("testing ");
}
}
 
Lalita Sattavat
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set ur classpath to current directory. which means execute the following on the command prompt

set CLASSPATH=.;%CLASSPATH%;

note: use ';' if ur working on windows and ':' if ur working on linux

now it should work fine
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to Java in General (Beginner) for follow-ups.
 
Seema Sehgal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
well, it seems you have not set your classpath and if u did so check r u storing your file with a same name as of class as "test.java".sumtimes while working with notepad u have to store file with double quotes like "test.java" while saving because sumtimes if u store file as test.java in notepad then the filename might be taken up as test.java.txt...so keep this too in mind.

hope it solves your problem..all the best..
seema
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As suggested above, I'd bet your CLASSPATH value could use changing. For an explanation of just what the CLASSPATH is, as well as for instructions on how to set it on different operating systems, take a look at our FAQ on HowToSetTheClasspath.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic