• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

err message

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when ever i compile any program on my system it compiles sucessfuly but when i run any program it gives error i don't know what to do the error message is as follows:
C:\jdk1.2\bin>javac example.java
C:\jdk1.2\bin>java example
Exception in thread "main" java.lang.NoClassDefFoundError: example
the example.java is as follows:
class example
{
public static void main(String args[])
{
System.out.println("This is my first java program.");
}
}
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First make sure that your path and classpath is set to or includes that directory.
Also make sure that your file name is example.java.
 
Dishi Malhotra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how class path is set
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how mine is set.
PATH c:\jdk1.2.1\bin;c:\jdk1.2.1\WHEREYOURCODEIS;c:\ora8;%PATH%;
set CLASSPATH=c:\jdk1.2.1\WHEREYOURCODEIS;c:\jdk1.2.1\bin;
You can either edit you autoexec file or I have a p.bat file that I uses to just concatenate the java files on the fly. That way I can switch versions of java without rebooting. I just edit the p.bat file, close the current DOS window and get a new window.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that mean CLASSPATH is that place where ur .class files are stored or the place where ur executables (javac,java) are....??
please confirm.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"path" should include the place where the SUN provided executables are.
CLASSPATH should contain the place that your application code is stored.
Here is an official definition:
http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/windows.html
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic