File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes why do I get NoClassDefFoundError???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why do I get NoClassDefFoundError????" Watch "why do I get NoClassDefFoundError????" New topic

why do I get NoClassDefFoundError????

northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
I am trying to run an java application but facing one major stubling block it does not want to run.
C:\java-coding\ftpbean-my2>java FtpExample
Exception in thread "main" java.lang.NoClassDefFoundError: FtpExample
Here is all the classes in the directory:
C:\java-coding\ftpbean-my2>dir *.class
Volume in drive C has no label
Volume Serial Number is 1631-1CEC
Directory of C:\java-coding\ftpbean-my2
FTPBEA~1 CLA 17,208 09-18-02 11:40p FtpBean.class
FTPREP~1 CLA 1,355 09-18-02 11:40p FtpReplyResourceBundle.class
FTPEXC~1 CLA 224 09-18-02 11:40p FtpException.class
FTPOBS~1 CLA 149 09-18-02 11:40p FtpObserver.class
FTPLIS~1 CLA 5,644 09-18-02 11:40p FtpListResult.class
SOCKET~1 CLA 275 09-18-02 11:40p SocketOpener$SocketFactory.class
SOCKET~2 CLA 724 09-18-02 11:40p SocketOpener$1.class
SOCKET~3 CLA 739 09-18-02 11:40p SocketOpener$2.class
SOCKET~4 CLA 895 09-18-02 11:40p SocketOpener$3.class
SOCKET~5 CLA 885 09-18-02 11:40p SocketOpener$4.class
SOCKET~6 CLA 701 09-18-02 11:40p SocketOpener$5.class
SOCKET~7 CLA 1,792 09-18-02 11:40p SocketOpener.class
FTPBEA~2 CLA 9,778 09-18-02 11:40p FtpBeanBeanInfo.class
FTPLIS~2 CLA 4,691 09-18-02 11:40p FtpListResultBeanInfo.class
FTPEXA~1 CLA 2,104 09-18-02 11:40p FtpExample.class
15 file(s) 47,164 bytes
0 dir(s) 4,370.62 MB free
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
This definitely looks like a CLASSPATH problem. Make sure that your class directory is in your CLASSPATH env variable

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
>Blake Minghelli
Yes it seems to be classpath problem
but I am not sure why?
I tried the program at another computer and the program worked there without changing a single line of code.
My autoexac.bat file is where I declare the classpath but it seems to be prettty much identical as the other PC apart from small differences like path.
Here is the path and classpath setting, can anyone spot anything I have missed?

PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\j2sdk1.4.0_01\BIN;C:\WINDOWS\jwsdp-1_0_01\bin;
SET CLASSPATH=C:\j2sdk1.4.0_01\BIN;C:\My_DL_Dap\java-ftp-dl\build; C:\My_DL_Dap\java-ftp-dl\build\ftp.jar;$CLASSPATH
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Every time you do a SET CLASSPATH=BLAHBLAH
you are replacing the previous BLAHBLAH with the
So to fix it put ;%CLASSPATH% at the end of each
and so on.
In that way you will accumulate all the classpath elements into one gigantic enormous CLASSPATH.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
How do I put comments in the autoexec.bat file?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
A bit of a side track, but it's
REM And now for something completely BASIC
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
Why do you keep quoting from Sun?
I am stymied.
My development of software is never for malicious concern.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Well, I just got some work for a nuclear power station, they wanna program for pulling rods in and out and stuff like that.
I agree. Here's the link:
subject: why do I get NoClassDefFoundError????
It's not a secret anymore!