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

run time error

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying to run this program but I'm getting run time error as:
Exception in thread "main" java.lang.NoClassDefFoundError: c:\raj\AQuestion.
raj is the file inwhich I have saved my program.I've been able to compile it but could not run it.Any suggestions?
public class AQuestion
{
public static void main(String args[])
{
AQuestion question = new AQuestion();
question.method(null);
question.func(12, 2);
question.func(12, 2.2);
}
public void method(Object o)
{
System.out.println("Object Verion");
}
public void method(String s)
{
System.out.println("String Version");
}
public void func(int i, int j)
{
System.out.println("Int Version");
}
public void func(int i, long j)
{
System.out.println("Long Version");
}
public void func(int i, double j)
{
System.out.println("Double Long Version");
}
public void func(long i, double j)
{
System.out.println("Double Int Version");
}
}
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you using to compile this program? I'm using javac.exe with jdk1.2.2_01 and this is what I get on the compile
C:\test>javac raj.java
raj.java:1: Public class AQuestion must be defined in a file called "AQuestion.java".
public class AQuestion
^
1 error
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!!
the program compiled & ran well.

i think its problem with some classpath for u
regards,
Preeti Pathak
 
Rajesh Gupta
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying but my path is:
set path = .;c:\:c:\jdk1.2.2\bin;%PATH%
As you can see carl my I'm using jdk1.2.2
 
Rajesh Gupta
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SORRY THE PATH IS:
set path = .;c:\:c:\jdk1.2.2\bin;"%PATH%"
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real point is, the source code has to be in a file called AQuestion.java and not raj. Thats a requirement in Java, the name of the source file and the name of the public class in the file must match and is case sensitive. Change the name of your file and, all should be well.
 
I'm still in control here. LOOK at this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic