• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No ClassDef found error

 
Sri Addanki
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have windows 2000 OS.
My java program compiles and runs fine with the textpad.
But when i do the same from DOS prompt, the java program compiles fine, but when i run it, it gives no ClassDef found error.
Why is this so?
I've double checked the classpath. What's the problem?
Thanks,
sri
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the classpath include "." (the current directory)?
[ March 11, 2003: Message edited by: Layne Lund ]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your classpath? Which directory is the compiled *.class file in?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that java cannot find a specified class in the classpath.
It does sound a bit unusually that TextPad works to run the app when you cannot do so at the command prompt. Sometimes, Microsoft's java.exe will interfere with things. In your PATH, I'd be certain that Sun's (or your preferred) java.exe is listed before any of Microsoft's system folders (such as /Windows or /Windows/System). I doubt that this is your problem though.
What is the value of your CLASSPATH?
 
Sri Addanki
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dirk, Layne , Marilyn,
Thanks and sorry for getting back so late....
Here's the path and the same i have in my classpath too. The problem still exists.
Any help.....
PATH=c:\;C:\J2SDK1~1.1\bin;C:\J2SDK1~1.1\lib;c:\lax\DEVELO~1;
My files are in c:\lax\developer\suncertify\ui\
folder.
suncertify is the package with 3 folders in it.
And also i have to tell you something in this regard.
My OS is Microsoft Windows 2000
[Version 5.00.2195],
This OS modified my long folder name formats all of a sudden, hence you see those tilda signs in the path. Don't know how to get back those long directory names, because its very painful to type the directory names with ~ signs. Any ideas?
Can someone please help.
Thanks,
sri
[ March 15, 2003: Message edited by: Sri Addanki ]
 
Samuel Fitzpatrick
Greenhorn
Posts: 10
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was having the same issue on windowsXP.
For a temporary fix, when you open your command line type
then, compile and run. Now its just temporary fix, you would need to do this every time you boot your computer.
What you will need to do is set your classpath system variable. Find the path to your tools.jar file, and add that to your classpath variable. Mine was
My entire classpath variable is

Hope that helps.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I do is:
1. Define JAVA_HOME as the place that I install the j2sdk
JAVA_HOME = C:\j2sdk1.4.1_02
2. PATH is where the system will look for executable programs like javac.exe, java.exe, javadoc.exe
PATH = %JAVA_HOME%\bin;%PATH%
The %PATH% is replaced by the "previous" definition of PATH, so C:\j2sdk1.4.1_02\bin gets prepended to the "previous" definition of PATH.
You should now be able to do java -version and see that (in this example) j2sdk 1.4.1_02 is being used.
3. In the simplest case you do not need to set CLASSPATH. Just cd to where your class files are (c:\lax\developer\suncertify\ui )and do java MyClass.
If you want to execute your classes from another directory you must have the class' directory in the CLASSPATH (or use the -classpath option to java).
CLASSPATH=c:\lax\developer\suncertify\ui;%CLASSPATH%
Now you should be able to do java MyClass from a directory other than c:\lax\developer\suncertify\ui. Try it from C:\temp if you have one.
It is also advisable to put the current directory in your CLASSPATH so you can cd into any directory and execute a class there. To do that you need . (a point) in your CLASSPATH.
CLASSPATH=.;c:\lax\developer\suncertify\ui;%CLASSPATH%

See the point and semicolon at the front?
The current directory is searched first, then c:\lax\developer\suncertify\ui, the whatever %CLASSPATH% resolves to.
Remember PATH and CLASSPATH are used for different purposes. And if in doubt, simplify to the minimum.
You will have to restart your DOS command session to see the changes. You can use echo %PATH% and echo %CLASSPATH% to see what the DOS command session thinks your PATH and CLASSPATH are.
[ March 16, 2003: Message edited by: Barry Gaunt ]
 
Sri Addanki
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot guys, I'll look into this today.
Sorry for getting back so late....I'm a bit occupied with work right now, hence couldn't get chance to look at the post.
thanks,
sri
 
Sri Addanki
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, yes i had to set my JAVAHOME variable.
Now i fixed it.
Thanks alot.
But now i have a strange problem.
I have Microsoft Windows 2000 [Version 5.00.2195] and if i enter >40 commandline characters, my DOS window doesn't show up any thing on the screen, and the key board starts giving a strange sound.
Please help me, thanks, sri
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't sound like a Java-based problem. I'd suggest that you mosey on over to The General Computing Forum, and see if they might have an idea.
 
Sri Addanki
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dirk for helping me.
Now my problem is:
Like for example to run some java program, i have to type this at c:\
java -cp %classpath%;C:\LAX\DEVELOPER -Djava.rmi.server.codebase=file:///c:\LAX\DEVELOPER
suncertify.db.RMIServer MyServer c:\LAX\DEVELOPER\suncertify\db\db.db
But my DOS window doesn't allow me to type the whole thing.
It starts yelling even before i get to type the entire command. Why?
Earlier, till 2 months back, i could type the entire command and run my program.
Thanks for the help.
sri
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
That doesn't sound like a Java-based problem. I'd suggest that you mosey on over to The General Computing Forum, and see if they might have an idea.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic