Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Help ! This code compiles but does not run: NoClassDefFoundError: Classpath info?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code compiles but does not run: NoClassDefFoundError
Exact error message:
C:\jdk1.3\bin>java Sum
Exception in thread "main"
java.lang.NoClassDefFoundError : Sum
Am i getting this because i have multiple jdk's
on my computer and that messed up the claspathing?
the Sum file is in the bin dir:
here the file:
//////////////////////////////////////////////////
// this code compiles but it does not run
// the error message i get is java Sum Exception in
// Thread "main" java.lang.NoClassDefFoundError: Sum
// i compile it in the dir D:\jdk.13\bin>
// do i need to set the classpath?
// my email is corradino@collegeclub.com

import javax.swing.JOptionPane;
public class Sum extends Object {

public static void main( String args[] )
{
int sum =0;
for ( int number =1; number <=100; number++)<br /> sum +=number;<br /> <br /> JOptionPane.showMessageDialog( null, " the sum is " + sum,<br /> "Sum integers from 1 to 100",<br /> JOptionPane.INFORMATION_MESSAGE );<br /> System.exit( 0 );<br /> }<br /> }<br /> /////////////////////////////////////////////////////<br /> <br /> I also tried C:\>c:jdk.13\bin\javac -classpath "
C:\jdk1.3\bin;" Sum.java
PS: this error never happened until i installed multiple
jdks and i also uninstalled all of them and reinstalled
jdk1.3 and i still get the same error!
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Erik,
i copied ur code in c:\>code directory & then

c:\code>javac Sum.java
c:>code>java Sum
the code compiled and ran perfectly.i'm using jdk 1.2.1 although
even i have installed so many versions of jdk . but in my case there is no problem.
can any body explain this
deekasha

 
Erik carine
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
( I have 2 computers winnt and win98 )
(My question is on making it work on winnt! )
I just did exactly what u did and I still got the same
error message! (on my winnt machine)
In winnt in autoexec.bat file i wrote this
PATH=C:\WINNT;C:\WINNT\COMMAND;C:\JDK1.3\BIN;
AND MY Sum.class file gave me the same error message!
before the path message i also tried putting this in the
autoexe.bat file:
SET PATH=%PATH;%JAVAHOME%\BIN

New Autoexe.bat file for win98
//=============================

SET BLASTER=A220 I7 D1 H7 P330 T6
SET SBPCI=C:\AUDIOPCI
SET QTJava=d:\jdk1.2.1\jre\lib\ext\QTJava.zip

SET CLASSPATH=%BIN%;
SET PATH=C:\JDK1.3\BIN;
SET PATH=%PATH%;C:\PROGRA~1\NETWOR~1\PGP
//========================================

//=======================================
this is the old one
SET BLASTER=A220 I7 D1 H7 P330 T6
SET SBPCI=C:\AUDIOPCI
SET QTJava=d:\jdk1.2.1\jre\lib\ext\QTJava.zip

SET CLASSPATH=%QTJava%;
SET PATH=C:\JAVA\BIN;C:\VIEWER5
SET PATH=%PATH%;C:\PROGRA~1\NETWOR~1\PGP

//=============================================

On win98 it seems like it does not matter!
( Sum works with jdk1.3 " compiles and runs" on my win98)
on my winnt machine the autoexe.bat file was 100%
empty and i still get this NoClassDef error on winnt
with or without an edit autoexec.bat file
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try setting path variable as follows
set path = %path%;c:\jdk1.2\bin;c:\jdk1.2\bin;
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic