Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2005

Tip: Looking for answers? Try searching our database.

java.lang.NoClassDefFoundError

Thread view: 
Frances Del Rio - 22 Apr 2005 17:27 GMT
I just tried running some stand-alone's I wrote/ran ok just a few months
ago..  they compiled fine but when tried to run got
java.lang.NoClassDefFoundError..

I had v 1.4 installed... just installed new version 1.5 update 2..  put
in same spot, file same name, etc..  so path info shouldd still be
valid, and indeed they compile fine.. but they won't run...

even this simple one I just wrote, compiles fine but won't run:

public class hello {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

get same error every time:

Exception in thread "main" java.lang.NoClassDefFoundError

exception in thread "main"???

thank you..  Frances
Fred L. Kleinschmidt - 22 Apr 2005 18:27 GMT
> I just tried running some stand-alone's I wrote/ran ok just a few months
> ago..  they compiled fine but when tried to run got
[quoted text clipped - 19 lines]
>
> thank you..  Frances

Sound like your class files are in a directory that is not part of
CLASSPATH
Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225

Ross Bamford - 24 Apr 2005 03:36 GMT
> > I just tried running some stand-alone's I wrote/ran ok just a few months
> > ago..  they compiled fine but when tried to run got
[quoted text clipped - 22 lines]
> Sound like your class files are in a directory that is not part of
> CLASSPATH

In this situation I'd recommended completely UNSETTING the classpath,
and just setting the environment variable JAVA_HOME to the main java
directory (i.e. the one ABOVE the lib/ and bin/ directories).

Example:

    export JAVA_HOME=/usr/java
    set JAVA_HOME=c:\progra~1\java

I have heard reports of such problems with Win32 / Long paths.

Hope that helps,
Ross Bamford
kaeli - 22 Apr 2005 18:36 GMT
> I just tried running some stand-alone's I wrote/ran ok just a few months
> ago..  they compiled fine but when tried to run got
> java.lang.NoClassDefFoundError..

CLASSPATH or PATH issue.
The classpath you compile with needs to match the one you run it with. And it
doesn't do that unless you set it to.
Echo those out and see what they are.
If you're using windows, just open up cmd and type
set
and hit enter to see all your env vars.

Signature

--
~kaeli~
A hangover is the wrath of grapes.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Frances Del Rio - 22 Apr 2005 19:02 GMT
>>I just tried running some stand-alone's I wrote/ran ok just a few months
>>ago..  they compiled fine but when tried to run got
[quoted text clipped - 7 lines]
> set
> and hit enter to see all your env vars.

thank you, kaeli..  this is very interseting..  a few days ago I had set
 the CLASSPATh to

C:\Program Files\mysql-connector-java-3.1.6\mysql-connector-java-3.1.6
-bin.jar

b/c I thought I needed to do that for MySQL, but yesterday, w/help from
someone right here, I managed to connect to db from Tomcat w/o this..
(by putting the connector-J .jar file in tomcat/common/lib.. and DELETED
THE CLASSPATH..  when I go to CP --> system --> advanced -- Env Vars..
IT'S NO LONGER THERE.. but if I do 'set' in cmd line, it shows CLASSPATH
still there...  this is so weird..

(following advice of countless folks in this ng I have never set
CLASSPATH for JVM or Tomcat .. just the path for the executables..
which I have not touched in months..) thank you again..  Frances


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.