Win a copy of Murach's Python Programming this week in the Jython/Python forum!
    Bookmark Topic Watch Topic
  • New Topic

can any body help me  RSS feed

 
Asanka Vithanage
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Report post to moderator
when i try to compile following code using command prompt.it gives following error.

class A {
public static void main(String s[]){

try{
throw new RuntimeException();

}

catch(Exception r){
System.out.println("asanka ");
}


}
}


C:\Documents and Settings\user\Desktop\java>javac A.java
A.java:7: cannot access RuntimeException
bad class file: .\RuntimeException.class
class file has wrong version 50.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
throw new RuntimeException();
^
1 error
what the hell this .???
i reinstalled java 3,4 times .and use the 1.5 and 1.6 also.but they also gives the sama problem.so i think this is os problems.so i unstalled the vista ultimate and installed windows xp.but the problem is same.so please help me
Following also gives same kind of error
class A {
public static void main(String s[]){
Thread a=new Thread();
}


}
this code give the following error
C:\Documents and Settings\user\Desktop\java>javac A.java
A.java:5: cannot access Thread
bad class file: .\Thread.java
file does not contain class Thread
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
Thread a=new Thread();
^
1 error
 
K Kiran Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Asanka,

What I feel is that for compiling, the version is taken as 1.5 but for referring the RuntimeException class, it is going for the class that is in 1.6 version. Better keep only one version and try out instead of installing two versions.

A similar instance can be found here http://forum.java.sun.com/thread.jspa?threadID=5144147&messageID=9987512 (even though the issue is related to web application).

Regards,
Kiran.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi asanka vithanage welcome to Javaranch.
the common reason for both the problems aboe is the classpath. Read this for the solution.
Also take a look at UseAMeaningfulSubjectLine, CarefullyChooseOneForum and UseCodeTags . So that you get more useful responses.

Hope this helps
[ October 24, 2008: Message edited by: Amit Ghorpade ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15860
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question in multiple JavaRanch forums.

I'm closing this one, since the question does not have anything to do with servlets.
[ October 24, 2008: Message edited by: Jesper Young ]
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!