This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am facing a weird problem. Whenever I am trying to execute a java program I get NoclassdefFound error and on including class path on command line I get bulk of error messages.
foll is a normal code which compiles error free(It is really a simple one)
I get this output:
Please tell me whats wrong in this?
thanks
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
Most likely, you have compiled the .java files with a more recent version of "javac" than the version of "java" you are using to execute it. Please use copy and paste not screenshots.
Execute the following commands:
java -version
javac -version
Examine your system and user PATH for older versions of Java preceding newer versions. If you are using -cp . then you have probably made some sort of mistake setting a classpath. It is usually a mistake to set a system classpath at all, so if you set a system classpath yourself, remove it. If the classpath was set automatically, add .; to its beginning.
Please post text for textual information rather than screenshots.
Edit: whoops, missed the previous exhortation; sorry.
Suvojit Chakraborty
Ranch Hand
Joined: Nov 10, 2009
Posts: 59
posted
0
Campbell Ritchie wrote:Most likely, you have compiled the .java files with a more recent version of "javac" than the version of "java" you are using to execute it.
Oh yes....I found the version of java as 1.3 in my system and javac as 1.6. Strangely, I dont know how Java interpreter became 1.3. Till yesterday everything was Ok and I was compiling and running my programs without any error.
But now I have installed JRE1.6 but still the problem persist.
please help to fix it.
Please use copy and paste not screenshots.
Ok I will take care of this in future.
Thanks
John de Michele
Rancher
Joined: Mar 09, 2009
Posts: 600
posted
0
Suvojit:
Did you change your path to make sure that the 1.6 version of java and javac are being called?
What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?
The System will pick up the first JDK/JRE it finds. Ideally you should have only one JAVA_HOME variable on your system which points to your Java installation directory.
What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?
I dont know what is this. I installed Oracle recently. Maybe it got installed along with oracle.
I will try to swap it with JDK's path. Let me see if this works......[fingers crossed]
What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?
The System will pick up the first JDK/JRE it finds. Ideally you should have only one JAVA_HOME variable on your system which points to your Java installation directory.
phew!!! at last its working.....I have put jdks path before oracles path.
Thank you mate.....u saved me from this mess, I was so frustrated...Thanks you so much....
now java n javac -version generates foll:
C:\Documents and Settings\suvojit123>javac -version
javac 1.6.0_20
C:\Documents and Settings\suvojit123>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
But I am still confused how and why did the classpath get swapped n whats is jre's connection with oracle....I am asking just out of curiosity. It will be great if you can anwser...
Like I mentioned before, the system will pick up the first JDK/JRE it finds.
I am guessing, someone installed some Oracle related stuff on your system. Maybe it came bundled with the 1.3 version?
Suvojit Chakraborty
Ranch Hand
Joined: Nov 10, 2009
Posts: 59
posted
0
Maneesh Godbole wrote:You mean the path, not classpath.
Yes
Like I mentioned before, the system will pick up the first JDK/JRE it finds.
I am guessing, someone installed some Oracle related stuff on your system. Maybe it came bundled with the 1.3 version?
Yes I installed oracle 9i recently.
I understood that java must have came bundled with it but what has java to do in oracle? This is my question.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
A lot of Oracle is written in Java and it is notorious for adding an old version of Java at the beginning of your PATH. Something to do with its installer.
You should delete that classpath environment variable altogether, and not put your work into those folders.